Can't Get Dim To Work...

  • 15 years ago
    Here's My Example Code...

    Option Explicit
    Public MyVariable as string , cnt as integer
    Dim MyVariable (1 to 100) , cnt (100)

    Do while cnt < 100
    Primary=MyVariable(cnt)
    cnt=cnt+1
    Loop

    label1.caption=val(Primary)

    My goel here, is to eventually be able to display whatever number in that array I wan't between 1-100 such as eg.#1 Label1.Caption=Val(Primary(5)) or something like this...???
    ' Running this program only displays the " Primary " as = " 0 "
    what am I doing wrong...I'm NEW to all this ...

    Any Precise Help would be appreciated...Thank's.


  • 15 years ago

     

    ok i dont know what your exact intensions are but if you want to say display a name stored in the variable "MyVariable" you initially have to put something in this variable

    ' general declarations

    Option Explicit
    Private MyVariable(1 to 100) as string

    public cnt as integer

    'form_load
    for cnt = 1 to 100
    MyVariable(cnt)  =   inputbox("Insert something here: Variable no - " & cnt)   ' this is where you set   'the string
    next


    'now this is where you recall the variable... "var" is what array value you want to call E.g 56
    label1.caption = myvariable(Val)

     

     

    try that.. need more help hit me back!

     

    init

  • 15 years ago

    Hi

    U can also use this method

    Option Explicit



    'now this is where you recall the variable... "var" is what array value you want to call E.g 56

    for i=1 to Ubound(myvariable)
       label1.caption = myvariable(Val)

    next i
    by

    Hari K

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.”