Solved

Problem to the codes

Posted on 2015-01-26
6
74 Views
Last Modified: 2015-01-26
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
0
Comment
Question by:HuaMinChen
6 Comments
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40570248
Due to some reason, I need to combine the lines of codes into one line, as shown in above.
0
 
LVL 18

Expert Comment

by:Simon
ID: 40570274
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?
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40570524
You have coded a VB.Net form of the statement.  Are you developing in VB.Net or VB6/VBA?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 40570600
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

0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 40571822
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
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 40571934
As stated before (twice), remove the type of the variable.

Change:

    Dim val1 As Integer :

To:

    Dim val1  :

Look closely at my example...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Issue with cURL on Windows 7 83
bash script to unzip a file 5 45
How to set the sa password in a vb6 code for sql connection 9 38
Copy dir and files with robocopy 2 36
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now