can not accommodate array VB.NET


Because it does not fit my records customerClient - customerName, this is my array in VB.NET

    Dim a As String
    a = Request.Form("numeroCliente")
    Dim b As String
    b = Request.Form("nombreCliente")

    Dim numeroCliente(,) As String = {{a} , {b}}

    For Each valor As String In numeroCliente

        For Each valor1 As String In numeroCliente

        Response.Write("El valor es numeroCliente " & valor & "nombreCliente" & valor1 )

places it this way

What I'm trying to do is to retrieve data that is in the rows of a table in an array to be able to insert them into a DB table

asked by Ivxn 27.05.2016 в 00:12

1 answer


You are traveling badly, with For Each you will travel sequentially, there is no way of saying what dimension to go through.

You should do it in the following way:

For x As Integer = 0 To numeroCliente.GetLength(0) - 1
      For y As Integer = 0 To numeroCliente.GetLength(1) - 1
          str = str + " " + numeroCliente(x, y)

With GetLength (num) you get the length of the specified dimension.

answered by 27.05.2016 / 01:05