Results 1 to 10 of 10

Thread: a simple race

  1. #1

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    a simple race

    Hi
    I am new to VB and I tried to race three cars(label) and I draw a finishin line .I want my program tell me which car won the race.
    **my second question is that I want my all three cars start the race when click the start button.



    Private Sub Command1_Click()
    Randomize
    Label4.Left = 6000
    aa = Int((Rnd * 500) + 1)
    bb = Int((Rnd * 500) + 1)
    cc = Int((Rnd * 500) + 1)
    label1.Left = label1.Left + aa
    label2.Left = label2.Left + bb
    label3.Left = label3.Left + cc
    If label1.Left = 5000 Then
    Print "blue car won"
    If label2.Left = 5000 Then
    Print "black car won"
    If label3.Left = 5000 Then
    Print "yellow car won"
    End If
    End If
    End If
    End Sub


    thanks if you correct my codes

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    post your progect

    but this code

    VB Code:
    1. If label1.Left = 5000 Then
    2. Print "blue car won"
    3. If label2.Left = 5000 Then
    4. Print "black car won"
    5. If label3.Left = 5000 Then

    should be

    VB Code:
    1. If label1.Left => 5000 Then
    2. Print "blue car won"
    3. If label2.Left => 5000 Then
    4. Print "black car won"
    5. If label3.Left => 5000 Then

    because your are assuming the left property will be exactly 5000

  3. #3
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711
    your forgot to put the END IF in
    put a end if on the next line after all the prints
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  4. #4

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    counter??

    Thanks Pino,
    I will try it

    and now please help me with the following question,

    I want my program write the numbers every time I click a button
    so that I know how many tmes I clicked it
    I do that in java script as
    counter=0;
    .......
    ........
    counter++
    how is it in VB?
    thanks a lot

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    the numbers? what numbers?

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    ok i made what i think your talkign about, the timer race races the cars every 500 milliseconds and the start race button just makes the casr moves once

  7. #7
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: counter??

    Originally posted by merhaba

    I want my program write the numbers every time I click a button
    so that I know how many tmes I clicked it
    I do that in java script as
    counter=0;
    .......
    ........
    counter++
    how is it in VB?
    thanks a lot
    it is real eassy to do, all u have to put in is a variable = the variable + 1
    for example:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim A as Long
    3. A = A + 1
    4. End Sub
    is that what u want?
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  8. #8

  9. #9
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Wokawidget
    Hahha...I couldn't help it

    Woka
    Thats the funniest thing I have seen since I started game programming....well we could need a goof bag like you in the Game section..

    BTW merhaba, for expert advices on game programming try to post in the game section next time...

  10. #10
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    BTW merhaba, for expert advices on game programming try to post in the game section next time...
    we handled it just fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width