rick
rick

Reputation: 931

Array not printing in 2D form inside a textBox in visualbasic

Private Sub Command4_Click()
  Dim x As Integer
  r = InputBox("Enter row size ")
  c = InputBox("Enter column size ")
  ReDim arr(r, c) As Integer
  For i = 0 To r - 1 Step 1
    For j = 0 To c - 1 Step 1
     arr(i, j) = InputBox("Enter row : " & (i + 1) & "column size : " & (j + 1))
    Next j
  Next i
  For i = 0 To r - 1
    For j = 0 To c - 1
      Text1.Text = Text1.Text & " " & arr(i, j)
  Next j
    Text1.Text = Text1.Text & vbNewLine & vbCr
 Next i
End Sub

This is my code for taking inputs in an array. Here everything is working fine except this line "Text1.Text = Text1.Text & vbNewLine & vbCr" here I am trying to print the array in row-column in 2D form inside a text box but its not happening "vbNewLine or vbcr" both are not working and my array is getting printed in a single line.

Upvotes: 0

Views: 569

Answers (1)

tcarvin
tcarvin

Reputation: 10855

I suggest vbCrLf instead of vbNewLine & vbCr, and you need to make sure you have your textbox set to Multiline in the properties editor.

Upvotes: 1

Related Questions