View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Call a proc inside itself (HELP)

Sub test()

Dim MyYear as Variant
Dim AnyString as String
AnyString = "Invalid Input"

Do
MyYear = Inputbox("type your date (yyyy)")

Select Case MyYear
Case 1900 to 2000
AnyString = "20th Century"
Case 2001 to 2050
AnyString = "Begining of 21Th Century"
Case else
AnyString = "Invalid input"
End Select

Msgbox AnyString
Loop While lcase(anystring) = "invalid input"
End sub


--
Regards,
Tom Ogilvy

"David" wrote in message
...
Hello,
I have a problem...
I call my proc inside itself and here's what happens...

for example :
****
Sub test()

Dim MyYear as Variant
Dim AnyString as String

MyYear = Inputbox("type your date (yyyy)")

Select Case MyYear
Case 1900 to 2000
AnyString = "20th Century"
Case 2001 to 2050
AnyString = "Begining of 21Th Century"
Case else
AnyThing = "This is not a valid Date"
' I'M HERE RECALLING THE SAME SUB SO I CAN HAVE THE INPUTBOX AGAIN
call test ' (or just test)
End Select

Msgbox AnyString
End sub
****

Unfortunatly... if i run my modules and for several time put something

else
than a number to my inputbox, it will run my inputbox several time but

ALSO
would run the MSGBOX ANYSTRING as much as time... so i have onr right
message and several-1 not as good !!

Can anyone tell me what i'm doing wrong PLEASE !
Thnx

David.