Silkroad Online Forums

A community forum for the free online game Silkroad Online. Discuss Silkroad Online, read up on guides, and build your character and skills.

Faq Search Members Chat  Register Profile Login

All times are UTC




Post new topic Reply to topic  [ 18 posts ] 
Author Message
 Post subject: VB MADNESS
PostPosted: Fri May 04, 2007 6:35 pm 
Banned User
Offline

Joined: Jun 2006
Posts: 4143
Location:
Babel
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

_________________
<<banned from SRF for bot admission. -SG>>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 6:40 pm 
Addicted Member
User avatar
Offline

Joined: Sep 2006
Posts: 2840
Location: HIV, CA
Whooza? I don't know bout that stuff sorry. :(

_________________
Peace.


Top
 Profile  
 
 Post subject: Re: VB MADNESS
PostPosted: Fri May 04, 2007 7:07 pm 
Valued Member
User avatar
Offline

Joined: Sep 2006
Posts: 385
Location: Where?
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"?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 7:09 pm 
Loyal Member
User avatar
Offline

Joined: Jun 2006
Posts: 1699
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.

_________________
Sig
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 7:32 pm 
Banned User
Offline

Joined: Jun 2006
Posts: 4143
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>>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 8:09 pm 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
il check over my class notes and see if i can figure it out but i actually failed that unit and now im farked because unit 8 is programming aswell :banghead:


html ftw though

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 9:01 pm 
Senior Member
User avatar
Offline

Joined: Nov 2006
Posts: 4526
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

_________________
Image
^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"


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 9:15 pm 
Frequent Member
User avatar
Offline

Joined: May 2006
Posts: 1062
Location: rehab
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.

_________________
Image
[Sparta][Pure STR][Lvl 5x]


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 10:04 pm 
Banned User
Offline

Joined: Jun 2006
Posts: 4143
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

_________________
<<banned from SRF for bot admission. -SG>>


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 10:12 pm 
Loyal Member
User avatar
Offline

Joined: Jun 2006
Posts: 1699
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.

_________________
Sig
"Never argue with an idiot. They will drag you down to their level and beat you with experience." Anonymous


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 10:37 pm 
Forum God
User avatar
Offline

Joined: Jan 2006
Posts: 9544
Location: London, United Kingdom
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

_________________
Image


I am not online much if you wish to get hold of me send me a private message with your email/discord and ill catch up with you.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 10:57 pm 
Loyal Member
User avatar
Offline

Joined: Jun 2006
Posts: 1699
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 11:01 pm 
Loyal Member
User avatar
Offline

Joined: Apr 2006
Posts: 1999
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.

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 11:17 pm 
Advanced Member
User avatar
Offline

Joined: Sep 2006
Posts: 2446
Location:
Off Topic
there are 2 ways to get it to work

either replace yout timer code with this

Code:
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 Sub


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

Code:
private sub procedure()
      code
      code
      if
              code
      elseif
              code
      end if
end sub

_________________
ImageImage


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 1:55 pm 
Banned User
Offline

Joined: Jun 2006
Posts: 4143
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

Quote:
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>>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 2:28 pm 
Site Contributor
User avatar
Offline

Joined: Oct 2006
Posts: 9541
Location: London
smeghead :P

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 2:43 pm 
Advanced Member
User avatar
Offline

Joined: Sep 2006
Posts: 2446
Location:
Off Topic
hmm. your not using vb.net are you? i cant stand that version

_________________
ImageImage


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 4:35 pm 
Banned User
Offline

Joined: Jun 2006
Posts: 4143
Location:
Babel
Innovacious wrote:
hmm. your not using vb.net are you? i cant stand that version


i think it is yes but i never look lol
i had to rewrite the whole program form scratch due to my MP3 player with my work on kicked the bucket

_________________
<<banned from SRF for bot admission. -SG>>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group