set a variable based on a user input

Posted on 2006-05-10
Last Modified: 2010-05-18
I am going mad.....

I am in no way a scripter, in fact, i am about as far away from a programming mind as the earth is from the sky so bare with me! hopefully this is simple

i have never scripted a thing in my life until a fortnight ago, nd jumped in at the deepend - decided to script my Active Directory Structure...... surprisingly enough, with much yelling, screaming and cursing i have got 95% of it complete even with variables cranking along! woohoo!!

now what i am struggling with is how to base a Variable, on user input

ie, i want my scirpt to when run prompt for a number for example, box pops up, says enter number and then the value that is entered becomes the value of the variable! i thought this would be easy so jumped onto google and experts and found nothing worked for me.

i have tried this  ===== set /p StoreNo=Please enter your Store Number: ===== to try and get it and declared the StoreNo Variable at the top of my script, however i run it and it errors right off!

i know there is something i am missing here and you guys will probably have a good laugh at my ignorance, but i have no idea and most of my script is copy, paste, edit!

i would like three different variables specified by user input when the script is run :) Please help me I am a networker and thats it!
Question by:Jay_Jay70
    LVL 44

    Accepted Solution

    Hello Jay_Jay70,

    assuming you use vbs you could start with something like this in a notepad and save it as test.vbs then run it and it will popup 3 boxes for user input

    dim strVar1, strVar2, strVar3

    strVar1 = InputBox("Enter a number")
    strVar2 = InputBox("Enter a name")
    strVar3 = InputBox("Enter a text")

    ' now check if the number is a number
    if IsNumeric(strVar1) Then
      ' do something
      ' do something else
      MsgBox "No valid entry for number"
    End If

    for samples for your topic you could look at

    hope this helps a bit
    LVL 48

    Author Comment

    you my friend, are a legend!

    dont know why i didnt post here 3 days ago, i am a regular and didnt even think about it!

    Thankyou very much :)

    is there any way to make that input box look any different or is that the default??
    LVL 44

    Expert Comment


    default properties of the box are

    InputBox (prompt, title, default, xpos, ypos)

    so you could also use something like
    InputBox ("Enter a number", "Number input", "5", 100, 100)
    LVL 48

    Author Comment

    good man :)
    LVL 44

    Expert Comment

    thanks for the grade and helping so many people around here :)
    LVL 48

    Author Comment

    and the same to you, your profile is huge! well done, its no small achievement reaching genius & wizard levels in multiple TA's

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    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…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    733 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