hi i made an input box that when you put the number of the program you want in it runs it that works. but i want to make the letter Q make it quit. i put in ElseIf
fname = Q Then
WScript.Quit
But every time i put Q in, an error keeps coming up saying "type mismatch: '[string: "Q"]' " here is my whole code:
Dim fname
Sub Run(ByVal sFile)
Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34), 1, false
Set shell = Nothing
End Sub
strMenu="Select a program" & VbCrLf &_
"1 HxD" & VbCrLf &_
"2 Johnson" & VbCrLf &_
"3 ConCept" & VbCrLf &_
"Q Quit"
do
fname=InputBox(strMenu,"Menu")
If fname = 1 Then
Run "C:\Documents and Settings\fix\Local Settings\Application Data\HxD\HxD.exe"
ElseIf fname = 2 Then
Run "C:\Documents and Settings\fix\My Documents\mods\programs\Johnson1.4_bin\Johnson.exe"
ElseIf fname = 3 Then
Run "C:\Documents and Settings\fix\My Documents\mods\programs\CONcept 0.3\CONcept.exe"
ElseIf fname = Q Then
WScript.Quit
END If
loop
I put The quit option in because i had to loop it so the input box wouldn't go away after it ran the program.
if you can give me an easier way to make the input box stay where it is please tell me but if you can't then just tell me whats wrong
thanks in advanced
You're doing a mathematical comparison, that's why you're getting a type mismatch. The easiest solution is to simply change your quit option to a number, such as 4 or 999. If you really want to keep it a letter, then you need to make it mathematical for the program. Here's an option.
------------------------------------------------------
Dim fname
If fname = 1 Then
Run "C:\Documents and Settings\fix\Local Settings\Application Data\HxD\HxD.exe"
ElseIf fname = 2 Then
Run "C:\Documents and Settings\fix\My Documents\mods\programs\Johnson1.4_bin\Johnson.exe"
ElseIf fname = 3 Then
Run "C:\Documents and Settings\fix\My Documents\mods\programs\CONcept 0.3\CONcept.exe"
ElseIf fname = 999 Then WScript.Quit
END If
loop
------------------------------------------------------
The above code is case sensitive, so you will need to enter a capital Q. You could obviously edit it if you wanted to be able to use a lower case q.