Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem to the codes

Hi,
Here are the codes

Dim val1 As Integer val1=InputBox("Enter a Number","Enter Value") Msgbox val1

Open in new window


and I don't know why I get the attached error.
t942.png
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

Due to some reason, I need to combine the lines of codes into one line, as shown in above.
Avatar of Simon
See MSDN VBScript Variables
In VBScript, variables are always of one fundamental data type, Variant.

If I remove the data type from your DIM statement and split it into separate lines, the code runs fine (in VBScript).
Dim val1 'As Integer 
val1=InputBox("Enter a Number","Enter Value") 
Msgbox val1

Open in new window


What is the reason you need the code on one line?
You have coded a VB.Net form of the statement.  Are you developing in VB.Net or VB6/VBA?
In addition to SimonAdept's correct solution on removing the type, if you want it all on one line then simply separate each line by a colon like this:
Dim val1 : val1=InputBox("Enter a Number","Enter Value") : Msgbox val1

Open in new window

Thanks all.

Sorry, I have put this

Dim val1 As Integer : val1=InputBox("Enter a Number","Enter Value") : Msgbox val1

Open in new window


but I still get the attached error

I need to put all into one line.
t943.png
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial