Results 1 to 3 of 3

Thread: Coding Error

  1. #1
    shenberry is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jan 2007
    Posts
    2
    Reputation
    0

    Coding Error

    Sorry If this is in the wrong location. It is very confusing on where I should put this information at, so I thought testing would be a good place to start.

    I am having trouble understanding why some controls can be in the form of control(1).property and others like textbox cannot be in that form. I am tryinig to insert 18 textboxes in to an array , so I can only input values one time. My coding looks like this

    Code:
       
           Dim t As Integer
            t = 1
            For i As Integer = 0 To 17
                Inputmatrices(i) = TextBox(t).Text
                t += 1
            Next i
    It doesn't allow me to generate different values for textboxes.
    The error it say is textbox is a type and cannot be used as an expression, how do I make it an expression.
    Thanks for the help

  2. #2
    Anti-Rich's Avatar
    Anti-Rich is offline VB.NET Forum Master
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jul 2006
    Location
    Perth, Australia
    Posts
    325
    Reputation
    131
    you need to create an instance of a textbox array...

    Code:
     
    dim tbArray() as TextBox
    and add the elements from there

    you can specify the length at the start (in the brackets), but if its dynamic you can use redim preserve to increase the array's capacity if you need to.

    good luck

  3. #3
    shenberry is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jan 2007
    Posts
    2
    Reputation
    0
    Thanks I classified an arry as textbox but sitll have an error with TextBoxN now. It wants it to be a variable and not a control.
    HEre is the complete coding.

    Code:
    Public Class Form1
    
        Dim TextBoxArray(17) As TextBox
    
     
        Private Sub TextBox28_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox28.TextChanged
            
        End Sub
    
        Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
            TextBox28.Text = "Addition"
        End Sub
    
        Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
            TextBox28.Text = "Subtraction"
        End Sub
    
        Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
            TextBox28.Text = "Multiplication"
            
        End Sub
    
        Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
            TextBox28.Text = "Identity"
    
        End Sub
    
        Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    
        Public Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InputMatrix.Click
            Dim N As Integer = 0
            TextBoxArray(N) = TextBoxN
            TextBoxArray(N + 1) = TextboxN + 1
        End Sub
    End Class

Bookmarks

Posting Permissions

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