Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 07-14-2008, 02:25 PM   #11
Daemon Poster
 
Join Date: Oct 2006
Posts: 684
Default Re: vb 2008 code problem

it still does it
__________________

ringtemek is offline   Reply With Quote
Old 07-14-2008, 02:28 PM   #12
Guru
 
JogaBonito1502's Avatar
 
Join Date: Jan 2008
Location: U.S.
Posts: 7,841
Default Re: vb 2008 code problem

Ok. I need to look at this again then.

Edit: I have no idea what is wrong. From the code it should be working perfectly.
Edit2: Aha! I found you're problem, maybe. When you set it to 1, are you leaving the others blank?

Code:
    Option Explicit
        Dim timer as boolean (This will be a global variable, accessed from everywhere)
    
    Form_load() (there should be something like this when you double click the form)
        timer = true

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim intsec as integer
        Dim intmin as integer
        Dim inthour as integer

        
        intsec = val(sec.text)
        intmin = val(min.text)
        inthour = val(hour.text)

        If timer = true then
            intsec = intsec - 1
            If (intsec = 0 or sec.text = "") and (intmin = 0 or min.text = "") and (inthour = 0 or hour.text = 0) Then
                timer = false
            else if intsec = 0 then
                if intmin > 0 then
                    intmin = intmin - 1
                    intsec = 59
                Else if intmin = 0 and inthour > 0 Then
                    inthour = inthour - 1
                    intmin = 59
                    intsec = 59
                End If
            End If
        end if

        sec.text = intsec
        min.text = intmin
        hour.text = inthour

(Else if might be elseif)
    End Sub
Ok, it's ready. I did some editing so if you saw this before this message update it.

Idk if those ORs I put in will work like that, but if you're leaving the fields blank, then you also need to check to see if they are blank on your code.
__________________

JogaBonito1502 is offline   Reply With Quote
Old 07-14-2008, 03:12 PM   #13
Daemon Poster
 
Join Date: Oct 2006
Posts: 684
Default Re: vb 2008 code problem

I got a warning on the following line of the code:

Code:
If (intsec = 0 Or sec.text = "") And (intmin = 0 Or min.text = "") And (inthour = 0 Or hour.text = 0) Then
all the other labels weren't blank
ringtemek is offline   Reply With Quote
Old 07-14-2008, 03:16 PM   #14
Guru
 
JogaBonito1502's Avatar
 
Join Date: Jan 2008
Location: U.S.
Posts: 7,841
Default Re: vb 2008 code problem

Code:
    Option Explicit
        Dim timer as boolean (This will be a global variable, accessed from everywhere)
    
    Form_load() (there should be something like this when you double click the form)
        timer = true

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim intsec as integer
        Dim intmin as integer
        Dim inthour as integer

        
        intsec = val(sec.text)
        intmin = val(min.text)
        inthour = val(hour.text)

        If timer = true and sec.text != "" and min.text != "" and hour.text != "" then
            intsec = intsec - 1
            If intsec = 0 and intmin = 0 and inthour = 0 Then
                timer = false
            else if intsec = 0 then
                if intmin > 0 then
                    intmin = intmin - 1
                    intsec = 59
                Else if intmin = 0 and inthour > 0 Then
                    inthour = inthour - 1
                    intmin = 59
                    intsec = 59
                End If
            End If
        end if

        sec.text = intsec
        min.text = intmin
        hour.text = inthour

(Else if might be elseif)
    End Sub
"!=" = is not equal to
Try to find out how to test whether text is numeric on not. This way you only accept numerical information. Also tell the user to input 0 even if they don't want hours.
JogaBonito1502 is offline   Reply With Quote
Old 07-14-2008, 03:23 PM   #15
Daemon Poster
 
Join Date: Oct 2006
Posts: 684
Default Re: vb 2008 code problem

Code:
sec.text != ""
identifier expected error

and was this script tested in visual basic
ringtemek is offline   Reply With Quote
Old 07-14-2008, 03:42 PM   #16
Daemon Poster
 
xtremezx2's Avatar
 
Join Date: Sep 2006
Posts: 915
Default Re: vb 2008 code problem

not equals in vb is denoted as "<>" not "!=", your in C land buddy. Might want to fix those up.
xtremezx2 is offline   Reply With Quote
Old 07-14-2008, 04:06 PM   #17
Daemon Poster
 
Join Date: Oct 2006
Posts: 684
Default Re: vb 2008 code problem

this is the codes i entered and now when i set it to 1 min it goes to 1 min -1 sec then stops

Code:
Dim timer As Boolean

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        timer = True
    End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim intsec As Integer
        Dim intmin As Integer
        Dim inthour As Integer


        intsec = Val(Sec.Text)
        intmin = Val(Min.Text)
        inthour = Val(Hour.Text)

        If timer = True Then
            intsec = intsec - 1
            If timer = True And Sec.Text <> "" And Min.Text <> "" And Hour.Text <> "" Then
                timer = False
            ElseIf intsec = 0 Then
                If intmin > 0 Then
                    intmin = intmin - 1
                    intsec = 59
                ElseIf intmin = 0 And inthour > 0 Then
                    inthour = inthour - 1
                    intmin = 59
                    intsec = 59
                End If
            End If
        End If

        Sec.Text = intsec
        Min.Text = intmin
        Hour.Text = inthour

    End Sub
ringtemek is offline   Reply With Quote
Old 07-14-2008, 04:48 PM   #18
Guru
 
JogaBonito1502's Avatar
 
Join Date: Jan 2008
Location: U.S.
Posts: 7,841
Default Re: vb 2008 code problem

No. I don't have VB. That might be C++ lol. I get confused all the time. Try <> instead of !=

Sorry, don't this any errors in the code man. I could be blindly missing something. Check to see if all your outputs are correctly assigned.
__________________

JogaBonito1502 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 05:01 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0