View Full Version : problems running VB Editor in Excel
Jimsta
02-07-2004, 02:26 AM
Im working on creating my own simulated book library using the VBEditor in Microsoft Excel. For now all it does is displays a screen in the main function that asks if you are using the program as a guest or administrator noted by a number.
When they enter a number, the appropriate method for the user/admin is executed, displaying a message(for now, gonna get fancy later :D).
I am getting no problems in terms of my syntax, but when I run the main method, it doesn't run at all :angry: No run time errors have been indicated to me by the compiler as well.
An interesting thing to also point out is that when i tried debugging the program, it skipped some of the lines in the main function(the ones that executed the user and admin methods). When I debugged the other 2 functions separately, I had no problems.
Now is there something I have failed to recognise when creating the VBCode or is Excel for Win XP a bit faulty in terms of the run-time environment. :o
The code has been attached below as a text file in the file attachment for your convenience
DNAunion2000
02-09-2004, 05:25 PM
Seems to me that the reason the User and Admin procedures aren't executing is because program flow never encounters their invocations (you even mention that those lines are never executed), and, that this is because the values associated with their Cases never occur. Doesn't InputBox return a character expression? If so, shouldn't the Cases be checking for charcter values instead of numeric ones?
Jimsta
02-11-2004, 09:00 PM
Originally posted by DNAunion2000
Seems to me that the reason the User and Admin procedures aren't executing is because program flow never encounters their invocations (you even mention that those lines are never executed), and, that this is because the values associated with their Cases never occur. Doesn't InputBox return a character expression? If so, shouldn't the Cases be checking for charcter values instead of numeric ones?
Upon clarifying with the VB Editor documentation (I'm using the XP version of VBEditor so there might be some difference in our respective versions of VBEditor), you can specify the return type in the type parametertype
Ive actually found its much easier to use the UserForms instead of InputBoxes now (i'm trying to create a library application), so I've managed to overcome the problem.
Thanks for your help anyway
DNAunion2000
02-11-2004, 11:05 PM
DNAunion: Seems to me that the reason the User and Admin procedures aren't executing is because program flow never encounters their invocations (you even mention that those lines are never executed), and, that this is because the values associated with their Cases never occur. Doesn't InputBox return a character expression? If so, shouldn't the Cases be checking for charcter values instead of numeric ones?
Jimsta: Upon clarifying with the VB Editor documentation (I'm using the XP version of VBEditor so there might be some difference in our respective versions of VBEditor), you can specify the return type in the type parametertype
The problem is that your invocation is wrong.
Here’s the syntax for the InputBox method (I am also using XP):
expression.InputBox(Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)
The Type parameter that you now mention is the 8th parameter, but you tried to specify a Type of 1 (for numeric return type) using the 3rd parameter.
’Jimsta’s code:
choice = Application.InputBox("Access Mode:" + Chr(13) + "1. User" + Chr(13) + "2. Admin", "Larry's Library", 1)
So the call does appear to be returning a text, because in the absence of a Type value to override the default Text return type, the default return type of Text is used.
Type Optional Variant. Specifies the return data type. If this argument is omitted, the dialog box returns text.
Jimsta
02-12-2004, 03:06 AM
thanks for that . I just re-read the documentation( lol realise how many mistakes u can do when ur coding late at night) and i forgot that i had to include the ":=" symbol so the correct parameters are specified for inputbox
e.g. inputbox(prompt:= "Jimsta code",type:=1)
I am on the right track now right ??
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.