Codigo fuente para verificar RIF en linea Venezuela
Publicado por Julio Calvache (95 intervenciones) el 20/08/2016 17:19:25
Crear una Tabla llamada "RIF" con los siguientes campos:
RazonSocial (Texto 180)
AgenteRetencion (Boolean)
Contribuyente ( Boolean)
Tasa (Numerico Double)
En esta tabla local es donde se graba los datos Fiscales del Seniat Venezuela, para luego uds consultalos como quieran....
Crear este código fuente en un Modulo:
RazonSocial (Texto 180)
AgenteRetencion (Boolean)
Contribuyente ( Boolean)
Tasa (Numerico Double)
En esta tabla local es donde se graba los datos Fiscales del Seniat Venezuela, para luego uds consultalos como quieran....
Crear este código fuente en un Modulo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Option Compare Database
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByReflpdwFlags As Long, ByVal dwReserved As Long) As Long
Public Function RifSeniatNombre(Rif As String)
On Error GoTo RifSeniatNombre_Err
Dim var As Variant
Dim vVarv As Variant
Dim htmlcode As Variant
Dim vRazon As String
Dim vAgente As Integer
Dim vContribuyente As Integer
Dim vTasa As Double
htmlcode = Null
If ComprobacionDeConexion = False Then
RifSeniatNombre = "SIN"
Else
gl_var = SysCmd(acSysCmdSetStatus, "Por favor espere.... Verificando el RIF : " & Rif & " en linea con el SENIAT....")
DoCmd.Hourglass True
vVarv = "http://contribuyente.seniat.gob.ve/getContribuyente/getrif?rif=" & Rif
URLDownloadToFile 0, vVarv, "c:\Rif.txt", 0, 0
Open "c:\Rif.txt" For Input As 1
Do While Not EOF(1)
Input #1, var
htmlcode = htmlcode & CStr(var) & vbNewLine
Loop
Close 1
Kill "c:\rif.txt"
Dim V1 As Variant
Dim V2 As Variant
Dim I, J As Integer
V1 = ""
V2 = ""
' Razon Social
For I = 1 To Len(htmlcode)
If Mid(htmlcode, I, 12) = "<rif:Nombre>" Then
For J = I + 12 To Len(htmlcode)
If Mid(htmlcode, J, 2) = "</" Then
Exit For
Else
V1 = V1 & IIf(Mid(htmlcode, J, 1) = Chr(13), " ", Mid(htmlcode, J, 1))
End If
Next
End If
Next
For I = 1 To Len(V1)
If Mid(V1, I, 1) = "(" Then
For J = I + 1 To Len(V1)
If Mid(V1, J, 1) = ")" Then
Exit For
Else
V2 = V2 & IIf(Mid(V1, J, 1) = Chr(13), " ", Mid(V1, J, 1))
End If
Next
End If
Next
If Len(V2) = 0 Then
RifSeniatNombre = Trim(V1)
Else
RifSeniatNombre = Trim(V2)
End If
vRazon = RifSeniatNombre
' AgenteRetencionIVA
V1 = ""
For I = 1 To Len(htmlcode)
If Mid(htmlcode, I, 24) = "<rif:AgenteRetencionIVA>" Then
For J = I + 24 To Len(htmlcode)
If Mid(htmlcode, J, 2) = "</" Then
Exit For
Else
V1 = V1 & IIf(Mid(htmlcode, J, 1) = Chr(13), " ", Mid(htmlcode, J, 1))
End If
Next
End If
Next
vAgente = IIf(V1 = "SI", -1, 0)
' Contribuyente
V1 = ""
For I = 1 To Len(htmlcode)
If Mid(htmlcode, I, 22) = "<rif:ContribuyenteIVA>" Then
For J = I + 22 To Len(htmlcode)
If Mid(htmlcode, J, 2) = "</" Then
Exit For
Else
V1 = V1 & IIf(Mid(htmlcode, J, 1) = Chr(13), " ", Mid(htmlcode, J, 1))
End If
Next
End If
Next
vContribuyente = IIf(V1 = "SI", -1, 0)
' Tasa
V1 = ""
For I = 1 To Len(htmlcode)
If Mid(htmlcode, I, 10) = "<rif:Tasa>" Then
For J = I + 10 To Len(htmlcode)
If Mid(htmlcode, J, 2) = "</" Then
Exit For
Else
V1 = V1 & IIf(Mid(htmlcode, J, 1) = Chr(13), " ", Mid(htmlcode, J, 1))
End If
Next
End If
Next
vTasa = V1
If Nz(DCount("Tasa", "RIF"), 0) > 0 Then
DoCmd.RunSQL "Update RIF Set RazonSocial = '" & vRazon & "', AgenteRetencion = " & vAgente & ", Contribuyente = " & vContribuyente & ", Tasa = " & vTasa
Else
DoCmd.RunSQL "Insert Into RIF ( RazonSocial, AgenteRetencion, Contribuyente, Tasa ) SELECT '" & vRazon & "'," & vAgente & "," & vContribuyente & "," & vTasa
End If
gl_var = SysCmd(acSysCmdClearStatus)
DoCmd.Hourglass False
End If
RifSeniatNombre_Exit:
Exit Function
RifSeniatNombre_Err:
gl_var = SysCmd(acSysCmdClearStatus)
DoCmd.Hourglass False
If err.Number = 53 Then
MsgBox "RIF : " & UCase(Rif) & " no esta registrado en el SENIAT.", vbCritical, "Atención"
Rif = ""
Else
MsgBox err.Description & " " & err.Number
End If
Resume RifSeniatNombre_Exit
End Function
Public Function ComprobacionDeConexion() As Boolean
On Error GoTo ComprobacionDeConexion_Err
ComprobacionDeConexion = InternetGetConnectedState(0&, 0&)
ComprobacionDeConexion_Exit:
Exit Function
ComprobacionDeConexion_Err:
MsgBox "Error nº " & err.Number & vbCrLf & err.Description & vbCrLf & "", vbCritical, "Aviso de error"
Resume ComprobacionDeConexion_Exit
End Function
Valora esta pregunta


0