Hello! I have the next problem: I am working with the code of an API of a famous brand of routers. With the API I can connect my computer to an access point and to obtain some information of the network.

With the following function, the API shows the information in a textbox:

Name:  funcion.png
Views: 260
Size:  1.5 KB

I know that the information shown in the textbox always follow the same format and I have a code with I can select the most important information that I need and to display it in a table. I have probed reading the information from a txt file and it works fine.

However, I want to make a little change in my code. I want to the application read the information directly from the text variable (not from the txt file).

This is my code:

Code:
Private Sub GetData_Click()
Grid1.Rows = 10  'filas de la tabla
Grid1.Clear
Grid1.TextMatrix(0, 0) = "Parámetro"    'Títulos de las columnas
Grid1.TextMatrix(0, 1) = "Valor actual"
Grid1.Visible = True 'Que se muestre la tabla de resultados sólo cuando se haga click en el botón
Dim sString As String
Dim fileNum As Integer
fileNum = FreeFile
Open App.Path & "\mensajeAPI.txt" For Input As #fileNum  'Abre el fichero donde están los datos
Dim y As Integer
Do While Not EOF(fileNum)       'Leer fichero
Line Input #fileNum, sString
If Mid(sString, 4, 4) = "mac-" Then

y = InStrRev(sString, "=")
Grid1.TextMatrix(1, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(1, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 4) = "rx-r" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(2, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(2, 1) = Mid(sString, y + 1)


End If
If Mid(sString, 4, 4) = "tx-r" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(3, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(3, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 4) = "pack" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(4, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(4, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 4) = "upti" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(5, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(5, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 4) = "last" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(6, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(6, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 16) = "signal-strength=" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(7, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(7, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 8) = "signal-t" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(8, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(8, 1) = Mid(sString, y + 1)
End If
If Mid(sString, 4, 16) = "signal-strength-" Then
y = InStrRev(sString, "=")
Grid1.TextMatrix(9, 0) = Mid(sString, 4, y - 4)
Grid1.TextMatrix(9, 1) = Mid(sString, y + 1)
End If
Loop
Grid1.ColAlignment(1) = 2
Close fileNum
End Sub

Private Sub Form_Load()
Grid1.Cols = 2
Grid1.ColWidth(0) = 3000
Grid1.ColWidth(1) = 3000
End Sub
Thank you!