Click to See Complete Forum and Search --> : Select Case


ant
June 16th, 2001, 08:30 AM
I have a toolbar with print,save,open, and new. but when i use select case, and i click on the button that says "new" it prints. What's wrong?

--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: cgeorge@thevortex.com
for the address

John G Duffy
June 16th, 2001, 08:36 AM
Your select Case choices are wrong or incomplete.

John G

ant
June 16th, 2001, 02:32 PM
How do you complete one?

--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: cgeorge@thevortex.com
for the address

John G Duffy
June 16th, 2001, 03:34 PM
Make sure all the values you are looking for are in a Case statement. IF they are not and you have a "Case Else" then "Case Else" will catch any values passed to the Select statement that do not meet your criteria.
If you are still having problems with your Select, post the code so someone can find out what you are doing wrong.

John G

ant
June 17th, 2001, 06:52 PM
Inside the Toolbar Click event:

Select Case tool
Case new
Dim f as Form2
set f = new Form2
f.show
Case print
Dim text
text = Richtextbox1.text
Printer.print Text
Printer.enddoc
Case save
' and it goes on and on
Case else
Msgbox "What!?"
End Select




--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: cgeorge@thevortex.com
for the address

pmmbala
June 17th, 2001, 11:09 PM
hi
try this..
i think u have to give double quot for the passing string . i mean new,print...

Select Case tool
Case "new"
MsgBox "new"
Case "print"
MsgBox "print"
Case "save"
MsgBox "save"
Case Else
MsgBox "What!?"
End Select

pmmbala_old
June 17th, 2001, 11:09 PM
hi
try this..
i think u have to give double quot for the passing string . i mean new,print...

Select Case tool
Case "new"
MsgBox "new"
Case "print"
MsgBox "print"
Case "save"
MsgBox "save"
Case Else
MsgBox "What!?"
End Select

John G Duffy
June 18th, 2001, 09:49 AM
A couple of suggested changes. Your select probably is not working because of the use or reserved words (ie print). I suspect you are using those words in your toolbuttons in which case it makes them strings. You need to encloise them in apostrophe's to use them as strings. Also when doing this you need to watch out for Upper/Lower case mixing. The lCase function will help in this regards.

private Sub Command1_Click()
Dim f as Form2 ' Moved
Select Case LCase(tool) ' Modified
Case "new" ' Modified
set f = new Form2
Dim text
text = Richtextbox1.text
Printer.print text
Printer.EndDoc
set f = nothing ' Added
Case "save" ' Modified
' and it goes on and on
Case else
MsgBox "What!?"
End Select
End Sub




John G