arielgatti444

Biblia de funciones

Jun 20th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BIBLIOTECA DE FUNCIONES
  2. -----------------------------------------------------------------------------------------
  3. public Function abrirRS(nombreTabla As String) as RecordSet
  4. Set abrirRS = oDB.OpenRecordset(nombreTabla, dbOpenDynaset)
  5. End Function
  6.  
  7. -----------------------------------------------------------------------------------------
  8.  
  9. public Sub cerrarRs(rs As Recordset)
  10.     rs.Close
  11.     set rs = Nothing
  12. end Sub
  13.  
  14. -----------------------------------------------------------------------------------------
  15. public Function buscarRegistro(NombreTabla As String, strCriterio as String) As Recordset
  16. Dim rs as RecordSet
  17. Set rs = abrirRS(NombreTabla)
  18.    
  19.     rs.FindFirst strCriterio
  20.     If not rs.NoMatch Then
  21.         Set buscarRegistro = rs
  22.     Else
  23.         set buscarRegistro = rs
  24.         cerrarRs(buscarRegistro)
  25.     End If
  26.  
  27. End Function
  28.  
  29. -----------------------------------------------------------------------------------------
  30. Public Sub llenarCombo(cbo As ComboBox, strTabla as String, strNombreCampoValor as String, strNombreCampoCodigo as String)
  31. Dim rs as RecordSet
  32. Set rs = abrirRS(strTabla)
  33.  
  34. cbo.clear
  35. cbo.AddItem "Seleccione una opcion"
  36. cbo.ItemData(cbo.NewIndex) = -1
  37. cbo.ListIndex = 0
  38.  
  39. Do While Not rs.EOF
  40.     cbo.AddItem rs(strNombreCampoValor)
  41.     cbo.ItemData(cbo.NewIndex) = rs(strNombreCampoCodigo)
  42.     rs.MoveNext
  43. Loop
  44.  
  45. rs.Close
  46. Set rs = Nothing
  47.  
  48. End Sub
  49. -----------------------------------------------------------------------------------------
  50. Public Sub llenarLst(lst As listBox, strTabla as String, strNombreCampoValor as String, strNombreCampoCodigo as String)
  51. Dim rs as RecordSet
  52. Set rs = abrirRS(strTabla)
  53.  
  54. lst.clear
  55. lst.AddItem "Seleccione una opcion"
  56. lst.ItemData(lst.NewIndex) = -1
  57. lst.ListIndex = 0
  58.  
  59. Do While Not rs.EOF
  60.     lst.AddItem rs(strNombreCampoValor)
  61.     lst.ItemData(lst.NewIndex) = rs(strNombreCampoCodigo)
  62.     rs.MoveNext
  63. Loop
  64.  
  65. rs.Close
  66. Set rs = Nothing
  67.  
  68. End Sub
  69. -----------------------------------------------------------------------------------------
  70. Public Function codigoCbo(cbo As ComboBox) as Long
  71.     codigoCbo = cbo.ItemData(cbo.ListIndex)
  72. End Function
  73.  
  74. -----------------------------------------------------------------------------------------
  75. Public Function codigoLst(lst As ListBox) as Long
  76.     codigoLst = lst.ItemData(cbo.ListIndex)
  77. End Function
  78.  
  79. -----------------------------------------------------------------------------------------
  80. Public Function formatFecha(strFecha as String) as Date
  81.     formatFecha = format(cDate(strFecha),"yyyy-mm-dd")
  82. End Function
  83.  
  84. -----------------------------------------------------------------------------------------
  85. Public Function formatFecha(feFecha as Date) as Date
  86.     formatFecha = format(feFecha,"yyyy-mm-dd")
  87. End Function
  88.  
  89. -----------------------------------------------------------------------------------------
  90. 'Validacion de Datos'
  91. -----------------------------------------------------------------------------------------
  92.  
  93. Public Function esNumerico(txtString as TextBox) as Boolean
  94.     If isNumeric(txtString.text) = true Then
  95.         esNumerico = True
  96.         else
  97.         esNumerico = False
  98.         MsgBox "El contenido no es numerico"
  99.     End If
  100. End Function
  101.  
  102. Public Function noEsStringVacio(txtString as TextBox) as Boolean
  103.     If txtString.text = "" Then
  104.         stringVacio = false
  105.         msgBox "El contenido no puede ser vacio"
  106.         else
  107.         stringVacio = true
  108. End Function
  109.  
  110. Public Function esFecha(txtFecha as String) as Boolean
  111.     If isDate(txtFecha) = true Then
  112.         esFecha = true
  113.         else
  114.         esFecha = false
  115.         msgBox "El contenido no corresponde a una fecha"
  116.     End If
  117. End Function
  118.  
  119. Public Function esPositivo(txtNumero as String) as Boolean
  120.     if Cint(txtNumero.text) >= o then
  121.         esPositivo = True
  122.         else
  123.         esPositivo = False
  124.         msgBox "El numero ingresado debe ser positivo"
  125. End Function
Advertisement
Add Comment
Please, Sign In to add comment