Results 1 to 7 of 7

Thread: Code works but is bulky. Any constructive suggestions?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    The problem with that is that it displays "A1" or "A2" etc rather than the message.

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Put the messages into a string array and select using the i variable you're looping with:

    for i = 1 to 3
    textbox(i).text = strMsgArray(i)
    next i


    Ooops, I just realized that the A1 etc are strings, that's what threw me. That's what I get for typing without reading CAREFULLY! :-) The above would work like this:

    dim A1 as string()
    redim A1(3)
    a1(1) = "message1"
    a1(2) = "message2"
    a1(3) = "message3"

    for i = 1 to 3
    textbox(i).text = A1(i)
    next i


    [This message has been edited by netSurfer (edited 01-20-2000).]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    Thank you so much!!!!!!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    I copied your code but It doesn't like the statement

    Dim A1 as string(). It doesn't like the parenthesis after string?

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    oops. it's dim A1() as string

    sorry about that :-)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    Dim A1 as string
    Dim A2 as string
    Dim A3 as String

    A1 = "Message1"
    A2 = "Message2"
    A3 = "Message3"

    If I write code and I want to do something like this:

    for i = 1 to 3
    TextBox.caption = A & i
    next

    I could write it like this but it is bulky:

    if i = 1 then
    TextBox.caption = A1
    else
    if i = 2 then
    TextBox.caption = A2
    else
    if i = 3 then
    TextBox.caption = A3
    End if
    Endif
    Endif

    Any Suggestions?


  7. #7
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    for i = 1 to 3
    textbox.text = "A" & i
    next i

    how's that?

    You could also, if you're working with several text boxes instead of one, mke them a control array (all same name with different indexes). Then do this:


    for i = 1 to 5
    textbox(i).text = "A" & i
    next i

    this would in textbox(1) put A1, textbox(2) - A2 etc

    [This message has been edited by netSurfer (edited 01-20-2000).]

Posting Permissions

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



Click Here to Expand Forum to Full Width