Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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?
 
Share this answer
 
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....
Try this:
VB
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
 
Share this answer
 
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
To your 2nd question :
VB
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
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900