VB MADNESS
-
Vandango
- Senior Member
- Posts: 4143
- Joined: Sat Jun 03, 2006 3:23 pm
- Quick Reply: Yes
- Location: Babel
VB MADNESS
right about know im coding a little program for my college assignment which is to make 5 lights show in a sequnce
now
there are 2 things
my teacher whos an exeprt programmer in a lot of langues Hex/Vb/Java and so on thinks this code is perfect yet there are still thing we could not figure out
Private Sub Timer1_Timer()
'ElseIf Shape2.FillStyle = 0 Then
'Shape2.FillStyle = 1 And Shape3.FillStyle = 0
'
'
'ElseIf Shape3.FillStyle = 0 Then
'Shape3.FillStyle = 1 And Shape4.FillStyle = 0
'
'
'ElseIf Shape4.FillStyle = 0 Then
'Shape4.FillStyle = 1 And Shape5.FillStyle = 0
'
'
'ElseIf Shape5.FillStyle = 0 Then
'Shape5.FillStyle = 1 And Shape1.FillStyle = 0
End Sub
ignore the ' i was trying to re write the code in order to get it working
Now For Some Reason it would Ignore the code in bold and stop there as i was trying to get the program to loop
also the program was also Ignoring the timer i had set for it yes this code was placed inside the timer event and properites of the timer were set correctly and for some reason it would still ignore the timer
i was wondering if you could figure out why it was ignoring the timer
i would give you the files for it to take a look at but i have no idea were to upload em
i also pmed curor but i think he might take a while to respond
now
there are 2 things
my teacher whos an exeprt programmer in a lot of langues Hex/Vb/Java and so on thinks this code is perfect yet there are still thing we could not figure out
Private Sub Timer1_Timer()
'ElseIf Shape2.FillStyle = 0 Then
'Shape2.FillStyle = 1 And Shape3.FillStyle = 0
'
'
'ElseIf Shape3.FillStyle = 0 Then
'Shape3.FillStyle = 1 And Shape4.FillStyle = 0
'
'
'ElseIf Shape4.FillStyle = 0 Then
'Shape4.FillStyle = 1 And Shape5.FillStyle = 0
'
'
'ElseIf Shape5.FillStyle = 0 Then
'Shape5.FillStyle = 1 And Shape1.FillStyle = 0
End Sub
ignore the ' i was trying to re write the code in order to get it working
Now For Some Reason it would Ignore the code in bold and stop there as i was trying to get the program to loop
also the program was also Ignoring the timer i had set for it yes this code was placed inside the timer event and properites of the timer were set correctly and for some reason it would still ignore the timer
i was wondering if you could figure out why it was ignoring the timer
i would give you the files for it to take a look at but i have no idea were to upload em
i also pmed curor but i think he might take a while to respond
<<banned from SRF for bot admission. -SG>>
- Blackchocob0
- Addicted Member
- Posts: 2840
- Joined: Fri Sep 29, 2006 7:33 am
- Quick Reply: Yes
- Location: HIV, CA
- Gul
- Valued Member
- Posts: 385
- Joined: Wed Sep 13, 2006 7:37 pm
- Quick Reply: Yes
- Location: Where?
- Contact:
Re: VB MADNESS
Karlos Vandango wrote:Private Sub Timer1_Timer()
'ElseIf Shape2.FillStyle = 0 Then
'Shape2.FillStyle = 1 And Shape3.FillStyle = 0
'
'
'ElseIf Shape3.FillStyle = 0 Then
'Shape3.FillStyle = 1 And Shape4.FillStyle = 0
'
'
'ElseIf Shape4.FillStyle = 0 Then
'Shape4.FillStyle = 1 And Shape5.FillStyle = 0
'
'
'ElseIf Shape5.FillStyle = 0 Then
'Shape5.FillStyle = 1 And Shape1.FillStyle = 0
End Sub
I've never coded in VB, but it looks like a bunch of syntax errors.
Aren't you supposed to have a "If" statement before even using an "ElseIf"?
Wheres the "End If"?
- Anh_Hung_Rom
- Loyal Member
- Posts: 1699
- Joined: Mon Jun 05, 2006 8:13 pm
- Quick Reply: Yes
- Location: Silicon Valley
It doesn't ignore the bold text. it fails there.
You do have the object Shape1 right?
Does the code for the other objects work? I mean, have you successfully force the program to execute the line above the bold text? Was this function fired before at all?
I don' t have a VB complier with me ATM. Paste the whole file and PM to me see if I can help.
You do have the object Shape1 right?
Does the code for the other objects work? I mean, have you successfully force the program to execute the line above the bold text? Was this function fired before at all?
I don' t have a VB complier with me ATM. Paste the whole file and PM to me see if I can help.
Sig
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous
-
Vandango
- Senior Member
- Posts: 4143
- Joined: Sat Jun 03, 2006 3:23 pm
- Quick Reply: Yes
- Location: Babel
Anh_Hung_Rom wrote:It doesn't ignore the bold text. it fails there.
You do have the object Shape1 right?
Does the code for the other objects work? I mean, have you successfully force the program to execute the line above the bold text? Was this function fired before at all?
I don' t have a VB complier with me ATM. Paste the whole file and PM to me see if I can help.
yes there all correct there just Named Shape1 Shape2 And So on till 5
<<banned from SRF for bot admission. -SG>>
- [SD]Master_Wong
- Forum God
- Posts: 9509
- Joined: Wed Jan 04, 2006 8:02 pm
- Quick Reply: Yes
- Location: Plymouth, University
- MastaChiefX
- Senior Member
- Posts: 4526
- Joined: Fri Nov 03, 2006 1:18 am
- Quick Reply: Yes
- Location: Life.
I would guess you havent intialized the Shape5. Or if you have, something is off.
Not the biggest fan of VB, and wong, html isnt much better lol
Not the biggest fan of VB, and wong, html isnt much better lol

^Thanks 0l3n!
Gone. Never really gone, but never really here.
"If Pac-Man had affected us as kids, we’d all be running around in dark rooms, munching pills and listening to repetitive electronic music"
- Rockshmo
- Frequent Member
- Posts: 1062
- Joined: Mon May 29, 2006 5:00 pm
- Quick Reply: Yes
- Location: rehab
- Contact:
Make sure all the shapes, timers, etc are initialized and like Gul said it seems like it's missing an If statement...
If Shape1.FillStyle = 0 Then
Shape1.FillStyle = 1 And Shape2.FillStyle = 0
^ Maybe? I dunno, it's hard to tell without seeing the rest of the code.. also I think you can replace "And" with && then again I haven't used anything for VB or written in VB for about 3 years now.
If Shape1.FillStyle = 0 Then
Shape1.FillStyle = 1 And Shape2.FillStyle = 0
^ Maybe? I dunno, it's hard to tell without seeing the rest of the code.. also I think you can replace "And" with && then again I haven't used anything for VB or written in VB for about 3 years now.
[Sparta][Pure STR][Lvl 5x]
-
Vandango
- Senior Member
- Posts: 4143
- Joined: Sat Jun 03, 2006 3:23 pm
- Quick Reply: Yes
- Location: Babel
Private Sub speed_Click()
If Text = "Slow" Then
Timer1.Interval = 2000
End If
'This will set the timer to run each light every 2 seconds
If Text = "Normal" Then
Timer1.Interval = 1000
End If
'This will set the timer to run each light every second
If Text = Fast Then
Timer1.Interval = 500
End If
'This will set the time to run each light every 0.5 seconds
If Text = Insane Then
Timer1.Interval = 250
End If
'This will set the timer to run each light ever 0.25 seconds
If Text = Godly Then
Timer1.Interval = 125
'This will set the timer to run each light ever 0.125 seconds
End If
End Sub
Private Sub start_Click()
Timer1.Enabled = True
'This will start the light show
End Sub
Private Sub stop_Click()
Timer1.Enabled = False
'This will stop the light show
End Sub
Private Sub Timer1_Timer()
If Shape1.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 0
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape2.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 0
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape3.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 0
Shape5.FillStyle = 1
ElseIf Shape4.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 0
ElseIf Shape5.FillStyle = 0 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
End If
End Sub
this is same thing but different code and it still dosent loop and again ignores the timer
Anh_Hung_Rom ive correct a few errors but its basicly the same code alos took out the last part
If Text = "Slow" Then
Timer1.Interval = 2000
End If
'This will set the timer to run each light every 2 seconds
If Text = "Normal" Then
Timer1.Interval = 1000
End If
'This will set the timer to run each light every second
If Text = Fast Then
Timer1.Interval = 500
End If
'This will set the time to run each light every 0.5 seconds
If Text = Insane Then
Timer1.Interval = 250
End If
'This will set the timer to run each light ever 0.25 seconds
If Text = Godly Then
Timer1.Interval = 125
'This will set the timer to run each light ever 0.125 seconds
End If
End Sub
Private Sub start_Click()
Timer1.Enabled = True
'This will start the light show
End Sub
Private Sub stop_Click()
Timer1.Enabled = False
'This will stop the light show
End Sub
Private Sub Timer1_Timer()
If Shape1.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 0
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape2.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 0
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape3.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 0
Shape5.FillStyle = 1
ElseIf Shape4.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 0
ElseIf Shape5.FillStyle = 0 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
End If
End Sub
this is same thing but different code and it still dosent loop and again ignores the timer
Anh_Hung_Rom ive correct a few errors but its basicly the same code alos took out the last part
<<banned from SRF for bot admission. -SG>>
- Anh_Hung_Rom
- Loyal Member
- Posts: 1699
- Joined: Mon Jun 05, 2006 8:13 pm
- Quick Reply: Yes
- Location: Silicon Valley
Put double quote around String value like "Godly". Try to compile your code.
Initialize the Shape1.FillStyle, shape2.FillStyle.... at the beginning. I'm not sure if you did.
Private Sub Timer1_Timer() is the function that supposed to be called every loop right? Replace the code with something simple, say a print statement, and make sure it's called correctly.
Initialize the Shape1.FillStyle, shape2.FillStyle.... at the beginning. I'm not sure if you did.
Private Sub Timer1_Timer() is the function that supposed to be called every loop right? Replace the code with something simple, say a print statement, and make sure it's called correctly.
Sig
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous
- [SD]Master_Wong
- Forum God
- Posts: 9509
- Joined: Wed Jan 04, 2006 8:02 pm
- Quick Reply: Yes
- Location: Plymouth, University
MastaChiefX wrote:I would guess you havent intialized the Shape5. Or if you have, something is off.
Not the biggest fan of VB, and wong, html isnt much better lol
ofc it isnt its a different language essentiially well for different things
i just prefer html myself i find it more simple
MaStEr

credits zelzin ^^

credits zelzin ^^
- Anh_Hung_Rom
- Loyal Member
- Posts: 1699
- Joined: Mon Jun 05, 2006 8:13 pm
- Quick Reply: Yes
- Location: Silicon Valley
HTML is not even a programming language wong.
Sig
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous
- Cruor
- Loyal Member
- Posts: 1999
- Joined: Wed Apr 12, 2006 1:22 am
- Quick Reply: Yes
- Location: Off topic
I have never even touched VB. Anyway, you say it only runs through the Timer1_Timer function once then stops? I looked at the Timer class on MSDN and it says something about using a "tick" event. I think the Timer1_Timer function is just being run through once because you don't have a "tick" event to call it repeatedly.

- Innovacious
- Advanced Member
- Posts: 2446
- Joined: Mon Sep 11, 2006 9:24 pm
- Quick Reply: Yes
- Location: Off Topic
- Contact:
there are 2 ways to get it to work
either replace yout timer code with this
or
change the fillstyle in all of the shapes properties to 0, if they are already on 0 then neither of these will fix it and i dont know what is wrong
edit: you also need to work on the presentation of the code, dosnt help it work better but there are certain naming conventions and stuff that are preffered by most programmers.
ok first of ll, the objects (text boxes, buttons etc) in this program for example a good way to name the buttons is cmdSpeed, cmdStart etc. This is a naming convention used by most people (cmd is short for command button) the same thing applies to text boxes, they would have txt at the begginging (txtText for example. not sure about the shapes, i never really use them.
also, indentation helps when reading the code, like this
either replace yout timer code with this
Code: Select all
Private Sub Timer1_Timer()
If Shape1.FillStyle = 1 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 1
Shape3.FillStyle = 0
Shape4.FillStyle = 0
Shape5.FillStyle = 0
ElseIf Shape2.FillStyle = 1 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 0
Shape3.FillStyle = 1
Shape4.FillStyle = 0
Shape5.FillStyle = 0
ElseIf Shape3.FillStyle = 1 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 0
Shape3.FillStyle = 0
Shape4.FillStyle = 1
Shape5.FillStyle = 0
ElseIf Shape4.FillStyle = 1 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 0
Shape3.FillStyle = 0
Shape4.FillStyle = 0
Shape5.FillStyle = 1
ElseIf Shape5.FillStyle = 1 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 0
Shape3.FillStyle = 0
Shape4.FillStyle = 0
Shape5.FillStyle = 0
End If
End Subor
change the fillstyle in all of the shapes properties to 0, if they are already on 0 then neither of these will fix it and i dont know what is wrong
edit: you also need to work on the presentation of the code, dosnt help it work better but there are certain naming conventions and stuff that are preffered by most programmers.
ok first of ll, the objects (text boxes, buttons etc) in this program for example a good way to name the buttons is cmdSpeed, cmdStart etc. This is a naming convention used by most people (cmd is short for command button) the same thing applies to text boxes, they would have txt at the begginging (txtText for example. not sure about the shapes, i never really use them.
also, indentation helps when reading the code, like this
Code: Select all
private sub procedure()
code
code
if
code
elseif
code
end if
end sub-
Vandango
- Senior Member
- Posts: 4143
- Joined: Sat Jun 03, 2006 3:23 pm
- Quick Reply: Yes
- Location: Babel
Yay i finnaly got it working this is the working code
Private Sub speed_Click()
If speed.Text = "Slow" Then
Timer1.Interval = 2000
End If
'This will set the timer to run each light every 2 seconds
If speed.Text = "Normal" Then
Timer1.Interval = 1000
End If
'This will set the timer to run each light every second
If speed.Text = "Fast" Then
Timer1.Interval = 500
End If
'This will set the time to run each light every 0.5 seconds
If speed.Text = "Insane" Then
Timer1.Interval = 250
End If
'This will set the timer to run each light ever 0.25 seconds
If speed.Text = "Godly" Then
Timer1.Interval = 125
'This will set the timer to run each light ever 0.125 seconds
End If
End Sub
Private Sub Start_Click()
Timer1.Enabled = True
'This will start the light show
End Sub
Private Sub Stop_Click()
Timer1.Enabled = False
'This will stop the light show
End Sub
Private Sub Timer1_Timer()
If Shape1.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 0
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape2.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 0
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape3.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 0
Shape5.FillStyle = 1
ElseIf Shape4.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 0
ElseIf Shape5.FillStyle = 0 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
End If
End Sub
0 is to make it Opaque(Spelling xD)
i only want 1 shape showing at a time
ill finsh this messege when i get home
Private Sub speed_Click()
If speed.Text = "Slow" Then
Timer1.Interval = 2000
End If
'This will set the timer to run each light every 2 seconds
If speed.Text = "Normal" Then
Timer1.Interval = 1000
End If
'This will set the timer to run each light every second
If speed.Text = "Fast" Then
Timer1.Interval = 500
End If
'This will set the time to run each light every 0.5 seconds
If speed.Text = "Insane" Then
Timer1.Interval = 250
End If
'This will set the timer to run each light ever 0.25 seconds
If speed.Text = "Godly" Then
Timer1.Interval = 125
'This will set the timer to run each light ever 0.125 seconds
End If
End Sub
Private Sub Start_Click()
Timer1.Enabled = True
'This will start the light show
End Sub
Private Sub Stop_Click()
Timer1.Enabled = False
'This will stop the light show
End Sub
Private Sub Timer1_Timer()
If Shape1.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 0
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape2.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 0
Shape4.FillStyle = 1
Shape5.FillStyle = 1
ElseIf Shape3.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 0
Shape5.FillStyle = 1
ElseIf Shape4.FillStyle = 0 Then
Shape1.FillStyle = 1
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 0
ElseIf Shape5.FillStyle = 0 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 1
Shape3.FillStyle = 1
Shape4.FillStyle = 1
Shape5.FillStyle = 1
End If
End Sub
change the fillstyle in all of the shapes properties to 0, if they are already on 0 then neither of these will fix it and i dont know what is wrong
0 is to make it Opaque(Spelling xD)
i only want 1 shape showing at a time
ill finsh this messege when i get home
<<banned from SRF for bot admission. -SG>>
- Innovacious
- Advanced Member
- Posts: 2446
- Joined: Mon Sep 11, 2006 9:24 pm
- Quick Reply: Yes
- Location: Off Topic
- Contact:


