Jump to content

Help with case

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
i need help with this how can i return back to first select case

thats the code i got
dim clicks as integer 

clicks = clicks + 1
select case 
case 1
msgbox "Hi"
case 2
msgbox "Bye"
end select 
now i want when theres no case anymore that i returns to case one and repeat everything again
this code comes in a command button and im using vb6

#2
Chambered

Chambered

    Newbie

  • Members
  • PipPip
  • 11 posts
You could create a while loop and a boolean variable. When you hit the end of the select statement, inside the Case Else part, set the variable to true. Then in each other case set the variable to false. So it'll keep looping until one of the cases is chosen.

#3
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
can you show an example code ?

cuz im pretty new with while loop and loop statment

#4
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Sorry but I read this like 5 times and I can't understand what you really want.

#5
kresh7

kresh7

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 661 posts
example:
dim clicks as integer 
clicks = clicks + 1 
select case 
case 1
timer1.enabled = true 
case 2
timer1.enabled = false
end select 
and now i want that when the person clicks again on the command button he goes again to case one and then 2 and then the hole starts again like an endless loop

#6
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Yeah.. but what is the purpose of this?????

It seems like you want to make that when the user clicks the timer starts and when he clicks again it stops, when clicked again it starts again, when clicked again it stops again etc.. right?? If yes then you SHOULD NOT use case, it's not the right technique to do this...

If Timer1.Enabled = False Then
Timer1.Enabled = True
Else: Timer1.Enabled = False
End If

AND PLEASE WHEN YOU INCLUDE SOME CODE USE TAGS!!

THANKS.