Results 1 to 8 of 8

Thread: General Array's Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64
    I jsut started using arrays, and have a question.

    I am trying to manually add data to arrays, below is some basic code:

    Code:
    'When Control Button Clicked, Textboxes (Array) are reset
    
    name(0) = ""
    name(1) = ""
    name(2) = ""
    name(3) = ""
    name(4) = ""
    name(5) = ""
    name(6) = ""
    name(7) = ""
    name(8) = ""
    name(9) = ""
    name(10) = ""
    name(11) = ""
    name(12) = ""
    name(13) = ""
    I continue to recieve "Wrong number of arguments or invalid property assignment" errors when using this code.

    Does anyone know what the problem could be?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Dim myArr(4) As String
    
        myArr(0) = "Hope"
        myArr(1) = "This"
        myArr(2) = "Works"
        myArr(3) = "Now"
        myArr(4) = "OK"
    
    Dim i as integer
      For i = lBound(myArr) to uBound(myArr)
        msgbox myarr(i)
      Next i
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Talking Maybe this?

    dim c as integer

    for ctxt = 1 to 13

    name(ctxt)=""

    next c
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    OOPS

    Dim ctxt as integer
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64
    Hmmm...problem though...

    name(0)
    name(1)
    ...etc

    They are text boxes. When i enter what HeSaidJoe wrote, i get a syntax error.

    Any suggestions?

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    if you are trying to call textboxes based on a name stored in a string, it won't work.
    You would need a control array and reference the index
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64
    How would I go about doing that?

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'perhaps this will let you get a grasp on it
    'start a new project
    'add 2 command buttons Command1 and Command2
    'add a textbox Text1
    '
    'then right click and copy the textbox
    'then right click and paste
    'will ask you if you want a control array
    'say yes
    'then delete the one you just pasted on the form
    
    run the job
    
    Option Explicit
    
    Public MaxId As Integer
    
    Private Sub Command1_Click()
        Dim i
        For i = 0 To Text1.Count - 1
          Text1(i) = "DirtBagDog"
        Next i
    End Sub
    
    'unload the textboxes
    
    Private Sub Command2_Click()
      Dim i As Integer
     For i = 1 To MaxId
       If MaxId < 1 Then Exit Sub   ' Keep first buttons.
       Unload Text1(i)          ' Delete last button.
       MaxId = MaxId - 1            ' Decrement button count.
       Text1(0).SetFocus       ' Reset button selection.
       Text1(0).Width = 4000
       Text1(0).Height = 400
    Next
    End Sub
    
    
    
    Private Sub Form_Load()
    'load 4 more textboxes
       MaxId = 4
       Dim i
       For i = 1 To MaxId
       Load Text1(i)     ' Create new button.
       
       ' Set new button under previous button.
       Text1(i).Top = Text1(i - 1).Top + 500
       Text1(i).Visible = True  ' Display new
                                     ' button.
       Text1(i).Width = 4000
       Text1(i).Text = "Command" & i + 1
       Next i
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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