Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BIBLIOTECA DE FUNCIONES
- -----------------------------------------------------------------------------------------
- public Function abrirRS(nombreTabla As String) as RecordSet
- Set abrirRS = oDB.OpenRecordset(nombreTabla, dbOpenDynaset)
- End Function
- -----------------------------------------------------------------------------------------
- public Sub cerrarRs(rs As Recordset)
- rs.Close
- set rs = Nothing
- end Sub
- -----------------------------------------------------------------------------------------
- public Function buscarRegistro(NombreTabla As String, strCriterio as String) As Recordset
- Dim rs as RecordSet
- Set rs = abrirRS(NombreTabla)
- rs.FindFirst strCriterio
- If not rs.NoMatch Then
- Set buscarRegistro = rs
- Else
- set buscarRegistro = rs
- cerrarRs(buscarRegistro)
- End If
- End Function
- -----------------------------------------------------------------------------------------
- Public Sub llenarCombo(cbo As ComboBox, strTabla as String, strNombreCampoValor as String, strNombreCampoCodigo as String)
- Dim rs as RecordSet
- Set rs = abrirRS(strTabla)
- cbo.clear
- cbo.AddItem "Seleccione una opcion"
- cbo.ItemData(cbo.NewIndex) = -1
- cbo.ListIndex = 0
- Do While Not rs.EOF
- cbo.AddItem rs(strNombreCampoValor)
- cbo.ItemData(cbo.NewIndex) = rs(strNombreCampoCodigo)
- rs.MoveNext
- Loop
- rs.Close
- Set rs = Nothing
- End Sub
- -----------------------------------------------------------------------------------------
- Public Sub llenarLst(lst As listBox, strTabla as String, strNombreCampoValor as String, strNombreCampoCodigo as String)
- Dim rs as RecordSet
- Set rs = abrirRS(strTabla)
- lst.clear
- lst.AddItem "Seleccione una opcion"
- lst.ItemData(lst.NewIndex) = -1
- lst.ListIndex = 0
- Do While Not rs.EOF
- lst.AddItem rs(strNombreCampoValor)
- lst.ItemData(lst.NewIndex) = rs(strNombreCampoCodigo)
- rs.MoveNext
- Loop
- rs.Close
- Set rs = Nothing
- End Sub
- -----------------------------------------------------------------------------------------
- Public Function codigoCbo(cbo As ComboBox) as Long
- codigoCbo = cbo.ItemData(cbo.ListIndex)
- End Function
- -----------------------------------------------------------------------------------------
- Public Function codigoLst(lst As ListBox) as Long
- codigoLst = lst.ItemData(cbo.ListIndex)
- End Function
- -----------------------------------------------------------------------------------------
- Public Function formatFecha(strFecha as String) as Date
- formatFecha = format(cDate(strFecha),"yyyy-mm-dd")
- End Function
- -----------------------------------------------------------------------------------------
- Public Function formatFecha(feFecha as Date) as Date
- formatFecha = format(feFecha,"yyyy-mm-dd")
- End Function
- -----------------------------------------------------------------------------------------
- 'Validacion de Datos'
- -----------------------------------------------------------------------------------------
- Public Function esNumerico(txtString as TextBox) as Boolean
- If isNumeric(txtString.text) = true Then
- esNumerico = True
- else
- esNumerico = False
- MsgBox "El contenido no es numerico"
- End If
- End Function
- Public Function noEsStringVacio(txtString as TextBox) as Boolean
- If txtString.text = "" Then
- stringVacio = false
- msgBox "El contenido no puede ser vacio"
- else
- stringVacio = true
- End Function
- Public Function esFecha(txtFecha as String) as Boolean
- If isDate(txtFecha) = true Then
- esFecha = true
- else
- esFecha = false
- msgBox "El contenido no corresponde a una fecha"
- End If
- End Function
- Public Function esPositivo(txtNumero as String) as Boolean
- if Cint(txtNumero.text) >= o then
- esPositivo = True
- else
- esPositivo = False
- msgBox "El numero ingresado debe ser positivo"
- End Function
Advertisement
Add Comment
Please, Sign In to add comment