Results 1 to 10 of 10

Thread: Array problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Berlin, Connecticut
    Posts
    17

    Unhappy Array problems

    ok for whatever reason i always like to make things difficult for myself.... that being said i need major help... heres my pr0blem....
    im just tooling around with this "fake" kinda data base i just set up a crap load of textboxes.... Labeled then txtName, txtaddress, txtcar, txtgolf (totally random things). then i made an array
    VB Code:
    1. dim array(4,5) as boolean
    (because i have 20 text boxes ... 4x5) how would i apply the array to the text boxes... i would like it .... like....

    (name) (address) ect
    text box textbox
    textbox text box
    ect ect

    plz help
    Remember im a n00b

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    like this mate?
    VB Code:
    1. Dim t(4, 5) As TextBox
    2.    Dim fake(,) As String = {{"name1", "address1", "telno1", "faxno1", "sts1"}, _
    3.       {"name2", "address2", "telno2", "faxno2", "sts2"}, _
    4.       {"name3", "address3", "telno3", "faxno3", "sts3"}, _
    5.       {"name4", "address4", "telno4", "faxno4", "sts4"}}
    6.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.    Dim i, j As Integer
    8.       Dim x As Integer = 10
    9.       Dim y As Integer = 10
    10.       For i = 0 To 3
    11.          For j = 0 To 4
    12.             t(i, j) = New TextBox()
    13.             t(i, j).Location = New Point(x, y)
    14.             t(i, j).Text = fake(i, j)
    15.             Controls.Add(t(i, j))
    16.             x += 110
    17.          Next
    18.          y += 25
    19.          x = 10
    20.       Next
    21.    End Sub
    if not, sorry.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You mean like

    VB Code:
    1. txtName.Text = myArray(0,0).ToString

    I can understand you being a newbie, but that doesn't mean you can't explain your problem well.

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    mendhak is right. You will have to sort out exactly what you are trying to achieve. We could go on guessing for hours.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    what is it you're trying to accomplish in the long run? that might help you out too.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Berlin, Connecticut
    Posts
    17
    sorry i was out all day guys..... ok lemme try to break it down into parts........
    First i made one form..... Form1 .... i put 4 text boxes in a groupbox, ((3 group boxes total) 4 textboxes in each) a label above each text box( different titles ...doesnt really matter what they are)) ... .
    then i made a second form..... Data.vb(or w/e)
    put 20 textboxes... in columns of 5 (4 collumns) top of each column is a different label..... SOOOOO lets just take one textbox at a time...
    If someone types there name in ( txtName(text box on form1)).. i wish for it to go in the Name collumn on the Data form. i figured i would have to use an array of some sort to automaticlly check if txtName1 (on Data form) is populated , and if it is ...to check the next number of the array (the next txt box.... txtName2)(just a sample of all my code).

    is an Array what i should be using?
    Remember im a n00b

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    So you're basically looking to transfer the text from one textbox to another textbox on another form.

    When does the actual transfer happen though? Do you want it while the user is entering it (meaning you have two forms open at the same time), or do you want it to occur after you close form1 and open form2?

  8. #8

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Berlin, Connecticut
    Posts
    17
    hehe i left out the east part....
    i have a button on the first form... when user presses it adds the info to the other textboxes on the other form then clears the first forms boxes... the second form never shows up... i just dont know how to create a database lol... so i made my own kinda...
    Remember im a n00b

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Location
    Berlin, Connecticut
    Posts
    17
    heres my starting code... maybe u can understand it better
    not even sure if an array is what i should use
    Data(form2)
    VB Code:
    1. Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
    2.         If Array(1, 1) = False And Array(2, 1) = False And Array(3, 1) = False And Array(4, 1) = False Then
    3.             Data.txtName1.Text = (inptname)
    4.             Data.txtAddress1.Text = (inptaddress)
    5.             Data.txtCar1.Text = (inptcar)
    6.             Data.txtGolf1.Text = (inptgolf)
    7.             Array(1, 1) = True
    8.             Array(2, 1) = True
    9.             Array(3, 1) = True
    10.             Array(4, 1) = True
    11.         Else
    12.             Data.txtName2.Text = (inptname)
    13.             Data.txtAddress2.Text = (inptaddress)
    14.             Data.txtCar2.Text = (inptcar)
    15.             Data.txtgolf2.Text = (inptgolf)
    16.             Array(1, 2) = True
    17.             Array(2, 2) = True
    18.             Array(3, 2) = True
    19.             Array(4, 2) = True
    20.         End If
    21.  
    22.     End Sub
    Remember im a n00b

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You can do something like this:

    VB Code:
    1. 'Module
    2.     Public arrValues(3, 0) As String
    3.     Public intArrSize As Integer = 0
    4.  
    5. 'form
    6.  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    7.         intArrSize = intArrSize + 1
    8.         ReDim Preserve arrValues(3, intArrSize)
    9.  
    10.         arrValues(0, intArrSize) = TextBox1.Text
    11.         arrValues(1, intArrSize) = TextBox2.Text
    12.         arrValues(2, intArrSize) = TextBox3.Text
    13.         arrValues(3, intArrSize) = TextBox4.Text
    14.  
    15.        
    16.  
    17.     End Sub

    But then, I'll save my 'comments' for later. Gotta rush now.

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