Solved

Problem to the codes

Posted on 2015-01-26
6
78 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 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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 
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 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exclude all *.dat files from a 7z.exe command line 13 43
Win 10 Automation Error with .doCmd in Access 2 90
Batch file to rename files. 12 41
Modify Text File with Excel Macro 13 49
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

734 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