2-1-Ctas_ctes-Buscar Datos WED
- Jamel Valentin Llanos
- 20 nov 2020
- 2 Min. de lectura
Actualizado: 22 nov 2020
Descarga: 2-1-Ctas_ctes-Buscar Datos WED
Continuando con el proyecto ahora desarrollamos un formulario para poder ingresar información de las cuentas corrientes (Clientes, proveedores, empleados, etc. Todo lo que se pueda relacionar con algún código).
Vamos a llenar la información consultando desde un API para que se haga las consultas por internet, puedes chequear estas publicación desde nuestro Facebook:
-BUSCAR RUC WED CON FORMULARIO https://fb.watch/1Ufzq2o7mi/
Espero que sea de su agrado:
Codigos:
rivate Sub BtBuscaWED_Click()
Call LimpiarDatos
If Len(TbCodigo) = 11 Then
Call CtaCteRUC
ElseIf Len(TbCodigo) = 8 Then
Call CtaCteDNI
Else
MsgBox ("MANUAL")
End If
End Sub
Sub obtenerDatoswed1()
Dim HtmlRespuesta As Object
Dim numero As String
numero = TbCodigo.Text
Set HtmlRespuesta = CreateObject("htmlfILE")
With CreateObject("msxml2.xmlhttp")
.Open "GET", "https://api.reniec.cloud/dni/" & numero, False
.SEND
PRUEBA = .RESPONSETEXT
End With
End Sub
Sub obtenerDatoswed2()
Dim HtmlRespuesta As Object
Dim numero As String
numero = TbCodigo.Text
Set HtmlRespuesta = CreateObject("htmlfILE")
With CreateObject("msxml2.xmlhttp")
.Open "GET", "https://api.sunat.cloud/ruc/" & numero, False
.SEND
PRUEBA = .RESPONSETEXT
End With
End Sub
Sub CtaCteRUC()
Call obtenerDatoswed2
Dim S() As String
S = Split(PRUEBA, ",")
TbNombres = Left(Right(S(1), Len(S(1)) - 23), Len(Right(S(1), Len(S(1)) - 23)) - 1)
TbDireccion = Left(Right(S(9), Len(S(9)) - 27), Len(Right(S(9), Len(S(9)) - 27)) - 1)
TbEstado = Left(Right(S(6), Len(S(6)) - 31), Len(Right(S(6), Len(S(6)) - 31)) - 1)
TbCondicion = Left(Right(S(4), Len(S(4)) - 34), Len(Right(S(4), Len(S(4)) - 34)) - 1)
TbTipo = "6"
TbRelacionada = "NO"
End Sub
Sub CtaCteDNI()
Call obtenerDatoswed1
Dim S() As String
S = Split(PRUEBA, ",")
TbNombres = Left(Right(S(2), Len(S(2)) - 27), Len(Right(S(2), Len(S(2)) - 27)) - 1) & " " & Left(Right(S(3), Len(S(3)) - 27), Len(Right(S(3), Len(S(3)) - 27)) - 1) & " " & Left(Right(S(4), Len(S(4)) - 18), Len(Right(S(4), Len(S(4)) - 18)) - 4)
TbDireccion = "-"
TbEstado = "-"
TbCondicion = "-"
TbTipo = "1"
TbRelacionada = "NO"
End Sub
Private Sub CbRelacionada_Click()
Dim Pregunta As String
Pregunta = MsgBox("La empresa tiene Relacion", vbYesNo + vbQuestion, "SELECCIONE")
If Pregunta = vbNo Then
TbRelacionada = "NO"
'Macros
Else
TbRelacionada = "SI"
End If
'End Sub
End Sub
Sub LimpiarDatos()
TbNombres = ""
TbTipo = ""
TbDireccion = ""
TbCtaCble = ""
TbCondicion = ""
TbEstado = ""
TbRelacionada = ""
End Sub
Sub CompletarDatos()
If TbCondicion = "" Then
TbCondicion = "-"
End If
If TbEstado = "" Then
TbEstado = "-"
End If
If TbDireccion = "" Then
TbDireccion = "-"
End If
If TbRelacionada = "" Then
TbRelacionada = "NO"
End If
If TbCtaCble = "" Then
TbCtaCble = "-"
End If
End Sub
Comments