Click here to Skip to main content
14,328,926 members
Rate this:
Please Sign up or sign in to vote.
See more:
hiii
I have problem in displaying the following array in textbox...
i am not getting the values in textbox.. getting error as "Conversion from string "" to type 'Double' is not valid."
please help me...
Thanx in advance...


 Dim values(,) As double = New double(,) {{"1", "1"},
       {"3", "4"},
       {"6", "4"},
       {"7", "10"},
       {"44", "9"}}
values= textbox1.text
Posted
Updated 12-Sep-19 2:23am
v3
Rate this:
Please Sign up or sign in to vote.

Solution 1

i am not getting the values in textbox.
You say you want to show array value in textbox but you write code for assigning textbox value in an array!

getting error as "Conversion from string "" to type 'Double' is not valid."
You get this error as you are trying to assign a string (textbox.text) to an array of type double. Invalid!

display of array in textbox
What exactly you are trying to display here? Whole array as a string? Array in matrix format? Or you want to access any specific value form array and display it?
   
Comments
arizan 29-Jun-12 1:08am
   
i want to display above array in matrix format..
i am new in vb.net so getting confused about coding....
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try this:
Dim value(,) As Double = New Double(,) {{1, 2}, {3, 4}, {5, 6}, {44, 66}}
       For i As Integer = 0 To UBound(value, 1)
           TextBox1.Text &= String.Format("{0}{1}{2}", value(i, 0).ToString.PadLeft(10), value(i, 1).ToString.PadLeft(10), vbNewLine)
       Next
   
Comments
arizan 29-Jun-12 1:27am
   
hey thanx its working.....
arizan 29-Jun-12 1:32am
   
hey and if i wanted to add the values from two different i.e from textbox1+textbox2 then displaying result in textbox3 what code should be given
Rate this:
Please Sign up or sign in to vote.

Solution 3

To your 2nd question :
Dim value(,) As Double = New Double(,) {{0, 0}}
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim maxDim0 As Integer = UBound(value, 1)
        Dim maxDim1 As Integer = UBound(value, 2) + 1

        ReDim Preserve value(maxDim0, maxDim1)
        value(maxDim0, 0) = Double.Parse(TextBox2.Text)
        value(maxDim0, 1) = Double.Parse(TextBox3.Text)

        For i As Integer = 0 To UBound(value, 1)
            TextBox1.Text &= String.Format("{0}{1}{2}", value(i, 0).ToString.PadLeft(15), value(i, 1).ToString.PadLeft(15), vbNewLine)
        Next
    End Sub
   
Comments
arizan 29-Jun-12 1:55am
   
hey getting the error as input string is not in correct format..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100