Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    California
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question VBS --> defining the variable every single time

    in this line from one of my scripts:

    dim ask, a, b, c, b1, b2, r, answer, user

    I defined every variable i was useing. Can i leave out all that and just write something like this without the "dim" and the long line of variables?

    x = "sgdfgd"
    msgbox (x)

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you have "Option Explicit" in the beginning of the script then you have to Dim your variables, otherwise you don't. But it is good practice to always use "Option Explicit" and Dim all the variables, because it can prevent bugs (like reusing a variable name by mistake).

    shmoove


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •