Solved

Problem to the codes

Posted on 2015-01-26
6
71 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:SimonAdept
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

757 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

20 Experts available now in Live!

Get 1:1 Help Now