Solved

Problem to the codes

Posted on 2015-01-26
6
80 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 11

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 46

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 86

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 11

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 86

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

636 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