| |  |  | Miembros: Mensajes: Temas: Online: Ultimo Miembro: | | |  | | |
 | 
31-10-2007, 07:22:17
| | Junior Member Site Admin | | Registrado: jun 2007 Posts: 14
| | Módulos de clase Hola amigos,
He empezado hace poco a programar en Visual Basic 6, porque en mi trabajo lo usan. Hasta ahora casi siempre había utilizado lenguajes de programacion Orientados a Objeto. Por lo que he leído VB6 no tiene clases, no? Esa es mi primera duda.
En segundo lugar, me gustaría saber ¿qué son los módulos de clase y para qué sirven? Ya que no entiendo muy bien su significado si no es un lenguaje OO y no tiene clases.
¿En qué se diferencia un módulo de clase de un módulo normal en VB6?
Espero que me aclareis un poco mis dudas.
Saludos a todos los foreros. | 
31-10-2007, 07:49:11
|  | Moderador | | Registrado: dic 2002 Ubicación: Madrid Posts: 4.307
| | Los módulos de clase de VB6 son precisamente eso, clases. Clases que se pueden instanciar, crear y destruir como en cualquier otro lenguaje orientado a objetos.
Por los puristas, VB6 está considerado como un lenguaje orientado a eventos y no a objetos, pues a pesar de disponer de clases y objetos, éstas no permiten ni herencia directa ni polimorfismo, lo que conlleva una pérdida considerable de las capacidades respecto de otros lenguajes.
No sé si este comentario te aclara la pregunta. | 
31-10-2007, 08:07:04
| | Junior Member Site Admin | | Registrado: jun 2007 Posts: 14
| | Sí que me ha aclarado, gracias.
Entonces, ¿me aconsejais que sólo use módulos normales para tener ahí todos los procedimientos de programación junto con las operaciones de consulta y actualización de la BD, o usais normalmente los módulos de clase, aunque es un inconveniente no tener herencia y polimorfismo??
Saludos. | 
31-10-2007, 09:26:51
|  | Moderador | | Registrado: dic 2002 Ubicación: Madrid Posts: 4.307
| | La verdad es que yo utilizo bastante los módulos de clase, me van estupendamente bien para mis propósitos y desde ellos realizo todo tipo de operaciones, incluso consultas a datos y cálculo numérico, generando en algunos casos librerías ActiveX que si están bien diseñadas, son una herramienta excelente.
Mi consejo es que experiementes y analices las ventajas e inconvenientes. | 
31-10-2007, 11:17:57
| | Junior Member Site Admin | | Registrado: jun 2007 Posts: 14
| | Gracias por todo, lo probaré y a ver si mejoro las aplicaciones que hay diseñadas en mi trabajo.
Saludos. | 
31-10-2007, 15:37:11
|  | Gran Participación en el Foro | | Registrado: dic 2006 Ubicación: Cancun,Quintana Roo Posts: 186
| | Hola amigo si puedes puedes comprar los controles de Sheridan, trae un programa que se llama CodeAssist y aqui te pongo una librerìa para que utilices este archivo lo debes de copiar en la carpeta de Templates(platillas), este programa lo que hace es generarte clases de una manera muy sencilla, solo creas una coneccion a tu Base de datos(SQL,Acces,MySQL,etc) y seleccionas la tabla a la cual le deseas crear la clase y listo. solo copias y agregas a tu Proyecto.
aqui te pongo un ejemplo de clase que genera este programa, Código: Option Explicit
'Date Created - 02/03/2007 10:03:58 a.m.
'Created by - Miguel Alejandro Lopez Montaño
Private Const MODULE_NAME = "clscAreas"
Private m_nId As Long
Private m_sDescripcion As String
Private m_sSocio As String
Private m_sCuentaBanco As String
Private m_bSeAcumula As Single
Private m_bEnResguardo As Single
Private m_sObservacion As String
Private m_bEstatus As Single
Private m_nIdUsuarioReg As Long
Private m_dFechaReg As Date
Private m_nIdUsuarioMod As Long
Private m_dFechaMod As Date
Private m_nIdUsuarioCan As Long
Private m_dFechaCan As Date
Private m_nFcAreas As Long
Public Property Let FcAreas(ByVal Value As Long)
m_nFcAreas = Value
End Property
Public Property Get FcAreas() As Long
FcAreas = m_nFcAreas
End Property
Public Property Let Id(ByVal Value As Long)
m_nId = Value
End Property
Public Property Get Id() As Long
Id = m_nId
End Property
Public Property Let Descripcion(ByVal Value As String)
m_sDescripcion = Value
End Property
Public Property Get Descripcion() As String
Descripcion = m_sDescripcion
End Property
Public Property Let Socio(ByVal Value As String)
m_sSocio = Value
End Property
Public Property Get Socio() As String
Socio = m_sSocio
End Property
Public Property Let CuentaBanco(ByVal Value As String)
m_sCuentaBanco = Value
End Property
Public Property Get CuentaBanco() As String
Socio = m_sCuentaBanco
End Property
Public Property Let SeAcumula(ByVal Value As Single)
m_bSeAcumula = Value
End Property
Public Property Get SeAcumula() As Single
Estatus = m_bSeAcumula
End Property
Public Property Let EnResguardo(ByVal Value As Single)
m_bEnResguardo = Value
End Property
Public Property Get EnResguardo() As Single
Estatus = m_bEnResguardo
End Property
Public Property Let Observacion(ByVal Value As String)
m_sObservacion = Value
End Property
Public Property Get Observacion() As String
Observacion = m_sObservacion
End Property
Public Property Let Estatus(ByVal Value As Single)
m_bEstatus = Value
End Property
Public Property Get Estatus() As Single
Estatus = m_bEstatus
End Property
Public Property Let IdUsuarioReg(ByVal Value As Long)
m_nIdUsuarioReg = Value
End Property
Public Property Get IdUsuarioReg() As Long
IdUsuarioReg = m_nIdUsuarioReg
End Property
Public Property Let FechaReg(ByVal Value As Date)
m_dFechaReg = Value
End Property
Public Property Get FechaReg() As Date
FechaReg = m_dFechaReg
End Property
Public Property Let IdUsuarioMod(ByVal Value As Long)
m_nIdUsuarioMod = Value
End Property
Public Property Get IdUsuarioMod() As Long
IdUsuarioMod = m_nIdUsuarioMod
End Property
Public Property Let FechaMod(ByVal Value As Date)
m_dFechaMod = Value
End Property
Public Property Get FechaMod() As Date
FechaMod = m_dFechaMod
End Property
Public Property Let IdUsuarioCan(ByVal Value As Long)
m_nIdUsuarioCan = Value
End Property
Public Property Get IdUsuarioCan() As Long
IdUsuarioCan = m_nIdUsuarioCan
End Property
Public Property Let FechaCan(ByVal Value As Date)
m_dFechaCan = Value
End Property
Public Property Get FechaCan() As Date
FechaCan = m_dFechaCan
End Property
Public Function Delete() As Boolean
On Error GoTo SQLServerDboCAreasDeleteError
Dim sSQL As String
Dim CMD As ADODB.Command
Dim nRowsAffected As Long
Delete = False
sSQL = "DELETE FROM cAreas"
sSQL = sSQL & " WHERE"
sSQL = sSQL & " Id = " & m_nId
Set CMD = New ADODB.Command
With CMD
.ActiveConnection = DemiData.cnCentral
.CommandText = sSQL
.CommandType = adCmdText
.Execute nRowsAffected
End With
Delete = True
SQLServerDboCAreasDeleteExit:
Exit Function
SQLServerDboCAreasDeleteError:
Call SysException.error(MODULE_NAME, "Delete")
Resume SQLServerDboCAreasDeleteExit
End Function
Public Function Update() As Boolean
On Error GoTo SQLServerDboCAreasUpdateError
Dim sSQL As String
Dim CMD As ADODB.Command
Dim nRowsAffected As Long
Update = False
sSQL = "UPDATE cAreas"
sSQL = sSQL & " SET"
sSQL = sSQL & " Descripcion = " & "'" & m_sDescripcion & "'" & ","
sSQL = sSQL & " CuentaBanco = " & "'" & m_sCuentaBanco & "'" & ","
sSQL = sSQL & " SeAcumula = " & m_bSeAcumula & ","
sSQL = sSQL & " EnResguardo = " & m_bEnResguardo & ","
sSQL = sSQL & " Socio = " & "'" & m_sSocio & "'" & ","
sSQL = sSQL & " Observacion = " & "'" & m_sObservacion & "'" & ","
sSQL = sSQL & " Estatus = " & m_bEstatus & ","
If m_bEstatus Then
sSQL = sSQL & " idUsuarioMod = " & m_nIdUsuarioMod & ","
sSQL = sSQL & " FechaMod = '" & Format(m_dFechaMod, "dd/mm/yyyy HH:MM AM/PM") & "'"
Else
sSQL = sSQL & " idUsuarioCan = " & m_nIdUsuarioMod & ","
sSQL = sSQL & " FechaCan = " & "'" & Format(m_dFechaMod, "dd/mm/yyyy HH:MM AM/PM") & "'"
End If
sSQL = sSQL & " WHERE"
sSQL = sSQL & " Id = " & m_nId
Set CMD = New ADODB.Command
With CMD
.ActiveConnection = DemiData.cnCentral
.CommandText = sSQL
.CommandType = adCmdText
.Execute nRowsAffected
End With
Update = True
SQLServerDboCAreasUpdateExit:
Exit Function
SQLServerDboCAreasUpdateError:
Call SysException.error(MODULE_NAME, "Update")
Resume SQLServerDboCAreasUpdateExit
End Function
Public Function Insert() As Boolean
On Error GoTo SQLServerDboCAreasInsertError
Dim sSQL As String
Dim CMD As ADODB.Command
Dim nRowsAffected As Long
Insert = False
sSQL = "INSERT cAreas ("
sSQL = sSQL & " Id,"
sSQL = sSQL & " Descripcion,"
sSQL = sSQL & " CuentaBanco,"
sSQL = sSQL & " SeAcumula,"
sSQL = sSQL & " EnResguardo,"
sSQL = sSQL & " Socio,"
sSQL = sSQL & " Observacion,"
sSQL = sSQL & " Estatus,"
sSQL = sSQL & " IdUsuarioReg,"
sSQL = sSQL & " FechaReg"
sSQL = sSQL & ") VALUES ("
sSQL = sSQL & " " & m_nId & ","
sSQL = sSQL & " " & "'" & m_sDescripcion & "'" & ","
sSQL = sSQL & " " & "'" & m_sCuentaBanco & "'" & ","
sSQL = sSQL & " " & m_bSeAcumula & ","
sSQL = sSQL & " " & m_bEnResguardo & ","
sSQL = sSQL & " " & "'" & m_sSocio & "'" & ","
sSQL = sSQL & " " & "'" & m_sObservacion & "'" & ","
sSQL = sSQL & " " & m_bEstatus & ","
sSQL = sSQL & " " & m_nIdUsuarioReg & ","
sSQL = sSQL & " " & "'" & Format(m_dFechaReg, "dd/mm/yyyy HH:MM AM/PM") & "'" & ""
sSQL = sSQL & ")"
Set CMD = New ADODB.Command
With CMD
.ActiveConnection = DemiData.cnCentral
.CommandText = sSQL
.CommandType = adCmdText
.Execute nRowsAffected
End With
Insert = True
SQLServerDboCAreasInsertExit:
Exit Function
SQLServerDboCAreasInsertError:
Call SysException.error(MODULE_NAME, "Insert")
Resume SQLServerDboCAreasInsertExit
End Function
Private Function GetDataFolio() As Boolean
On Error GoTo FOLIOGetDataError
Dim sSQL As String
Dim RS As ADODB.Recordset
GetDataFolio = False
Set RS = New ADODB.Recordset
sSQL = "SELECT"
sSQL = sSQL & " F_cAreas"
sSQL = sSQL & " FROM FoliosSys"
Set RS.ActiveConnection = DemiData.cnCentral
RS.Open sSQL
If RS.RecordCount Then
m_nFcAreas = inCaseNull(RS.Fields!F_cAreas)
GetDataFolio = True
End If
FOLIOGetDataExit:
If Not RS Is Nothing Then
If RS.State = adStateOpen Then
RS.Close
End If
Set RS = Nothing
End If
Exit Function
FOLIOGetDataError:
Call SysException.error(MODULE_NAME, "Obtiene Folio")
Resume FOLIOGetDataExit
End Function
Private Function UpdateFolio() As Boolean
On Error GoTo FOLIOUpdateError
Dim sSQL As String
Dim CMD As ADODB.Command
Dim nRowsAffected As Long
UpdateFolio = False
sSQL = "UPDATE FoliosSys"
sSQL = sSQL & " SET"
sSQL = sSQL & " F_cAreas = " & m_nFcAreas + 1
Set CMD = New ADODB.Command
With CMD
.ActiveConnection = DemiData.cnCentral
.CommandText = sSQL
.CommandType = adCmdText
.Execute nRowsAffected
End With
UpdateFolio = True
FOLIOUpdateExit:
Exit Function
FOLIOUpdateError:
Call SysException.error(MODULE_NAME, "Actualizar Folio")
Resume FOLIOUpdateExit
End Function
Public Function Incrementar() As Boolean
On Error GoTo Incrementar_Error
Incrementar = False
If GetDataFolio Then
If UpdateFolio Then
Incrementar = True
End If
End If
Incrementar_Done:
Exit Function
Incrementar_Error:
Call SysException.error(MODULE_NAME, "Incrementar")
Resume Incrementar_Done
End Function
Public Function TomarFolio() As Long
On Error GoTo TomarFolio_Error
TomarFolio = 0
If GetDataFolio Then
TomarFolio = m_nFcAreas
End If
TomarFolio_Done:
Exit Function
TomarFolio_Error:
Call SysException.error(MODULE_NAME, "TomarFolio")
Resume TomarFolio_Done
End Function claro tambien tu puedes adecuar tus plantillas
en cuanto a esos controles trae muchos mas que te gustaran
saludos y cualquier comentario estoy para ayudarte
__________________
Saludos desde Cancùn...
Alex malm Código: Pienso primero luego programo | 
31-10-2007, 18:36:49
| | Junior Member Site Admin | | Registrado: jun 2007 Posts: 14
| | Me podeis indicar alguna página o tutorial donde pueda ver la sintaxis para definir las clases, atributos, constructores de los objetos y demás.... en definitiva cómo utilizar la OO en VB6
Saludos y gracias a todos!!! | 
31-10-2007, 19:46:15
|  | Gran Participación en el Foro | | Registrado: dic 2006 Ubicación: Cancun,Quintana Roo Posts: 186
| |
__________________
Saludos desde Cancùn...
Alex malm Código: Pienso primero luego programo | 
01-11-2007, 16:09:00
| | Junior Member Site Admin | | Registrado: jun 2007 Posts: 14
| | Muchas gracias, lo estudiaré y os expondré mis dudas sobre las clases en VB6
Saludos a todos!!! | | Herramientas | | | | Desplegado | Mode Lineal |
Normas de Publicación
| no Puedes crear nuevos temas no Puedes responder a temas no Puedes adjuntar archivos no Puedes editar tus mensajes Código [IMG] está habilitado Código HTML está deshabilitado | | | La franja horaria es GMT. Ahora son las 23:28:16.
Powered by vBulletin® Version 3.6.8 Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
A vBSkinworks Design
|  |