hola tengo un module que no me acuerdo de donde me lo descargue . pero cuando intento yamar a esta funcion me da argumento no opcional
CitarPublic Function GetStringVal(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String, ByVal strValue As String) As String
Dim KeyHnd As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim lValueType As Long
Dim intZeroPos As Integer
r = RegOpenKey(Hkey, SubKey, KeyHnd)
lResult = RegQueryValueEx(KeyHnd, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String$(lDataBufSize, " ")
lResult = RegQueryValueEx(KeyHnd, strValue, 0&, 0&, ByVal strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos > 0 Then
GetStringVal = Left$(strBuf, intZeroPos - 1)
Else
GetStringVal = strBuf
End If
End If
Else
Err.Raise vbObjectError + 513, strValue, strValue
End If
End Function
AK LES DEJO EL CODIGO DEL MODULO
CitarOption Explicit
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'FIXIT: As Any is not supported in Visual Basic .NET. Use a specific type. FixIT90210ae-R5608-H1984
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
'FIXIT: As Any is not supported in Visual Basic .NET. Use a specific type. FixIT90210ae-R5608-H1984
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Enum HKEYRegConstants
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
End Enum
Public Const ERROR_SUCCESS = 0&
Public Const REG_SZ = 1
Public Const REG_DWORD = 4
Public r As Long
Public Sub CreateKey(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String)
Dim KeyHnd&
r = RegCreateKey(Hkey, SubKey, KeyHnd&)
r = RegCloseKey(KeyHnd&)
End Sub
Public Function GetStringVal(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String, ByVal strValue As String) As String
Dim KeyHnd As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim lValueType As Long
Dim intZeroPos As Integer
r = RegOpenKey(Hkey, SubKey, KeyHnd)
lResult = RegQueryValueEx(KeyHnd, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String$(lDataBufSize, " ")
lResult = RegQueryValueEx(KeyHnd, strValue, 0&, 0&, ByVal strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos > 0 Then
GetStringVal = Left$(strBuf, intZeroPos - 1)
Else
GetStringVal = strBuf
End If
End If
Else
Err.Raise vbObjectError + 513, strValue, strValue
End If
End Function
Public Sub SaveStringVal(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String, ByVal SubString As String, ByVal Value As String)
Dim KeyHnd As Long
Dim r As Long
r = RegCreateKey(Hkey, SubKey, KeyHnd)
r = RegSetValueEx(KeyHnd, SubString, 0, REG_SZ, ByVal Value, Len(Value))
r = RegCloseKey(KeyHnd)
End Sub
Function GetDwordVal(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String, ByVal strValueName As String) As Long
Dim lResult As Long
Dim lValueType As Long
Dim lBuf As Long
Dim lDataBufSize As Long
Dim r As Long
Dim KeyHnd As Long
r = RegOpenKey(Hkey, SubKey, KeyHnd)
lDataBufSize = 4
lResult = RegQueryValueEx(KeyHnd, strValueName, 0&, lValueType, lBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
If lValueType = REG_DWORD Then
GetDwordVal = lBuf
End If
End If
r = RegCloseKey(KeyHnd)
End Function
Function SaveDwordVal(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String, ByVal strValueName As String, ByVal lData As Long) As Long
Dim lResult As Long
Dim KeyHnd As Long
Dim r As Long
r = RegCreateKey(Hkey, SubKey, KeyHnd)
lResult = RegSetValueEx(KeyHnd, strValueName, 0&, REG_DWORD, lData, 4)
r = RegCloseKey(KeyHnd)
End Function
Public Function DeleteKey(ByVal Hkey As HKEYRegConstants, ByVal strKey As String) As Long
r = RegDeleteKey(Hkey, strKey)
End Function
Public Function DeleteValue(ByVal Hkey As HKEYRegConstants, ByVal SubKey As String, ByVal strValue As String) As Long
Dim KeyHnd As Long
r = RegOpenKey(Hkey, SubKey, KeyHnd)
r = RegDeleteValue(KeyHnd, strValue)
r = RegCloseKey(KeyHnd)
End Function
COMO HAGO PARA Q TODO ESO SE CARGUE EN UN TXTBOX PARA DESPUES PASARLO A UNA LISTA O A OTRA COSA
No entiendo bien que quieres hacer. Qué deseas cargar en un textbox? especifica por favor para poder ayudarte!
Cita de: rembolso en 12 Junio 2009, 06:27 AM
hola tengo un module que no me acuerdo de donde me lo descargue . pero cuando intento yamar a esta funcion me da argumento no opcional
Ese error aparece cuando FALTAN ARGUMENTOS EN UNA FUNCION (Estos argumentos deben ser del mismo tipo del argumento de la funcion/proceso/etc.) para que esta Trabaje adecuadamente por ejemplo:
public function sumar(byval num1 as integer,byval num2 as integer,optional byval num3 as integer) as integer
'Se requiere que metas el valor de la variable Num1 y de Num2 sIEMPRE NUMERICOS DE TIPO ENTERO 'Integer'
'NUM3 es opcionla y puede o no ser asignado un 'X' Numero
suma=num1+num2+num3
end function
En algún proceso 'X'
Por ende esta se puede llamar de DOS formas
dim res as integer
res= sumar(10,10)
msgbox res
o de igual forma
dim res as integer
res=sumar(10+10+12)
msgbox res
Cabe destacar que cuando se asigna opcional un parametro de una funcion este si no le es asignado un valor al momento de llamalo obtiene el valor POR DEFAULT esn este caso será cero por ser tipo numerico y si es textual seria nada de texto, igual podria ser el valor que se le implanta a la Funcion/Proseso/X en cuention
public function sumar(byval num1 as integer,byval num2 as integer,optional byval num3 as integer=999) as integer
'Se requiere que metas el valor de la variable Num1 y de Num2 sIEMPRE NUMERICOS DE TIPO ENTERO 'Integer'
'NUM3 es opcionla y puede o no ser asignado un 'X' Numero
suma=num1+num2+num3
end function
en la funcion anterior si no se asigna un valor a num3 este por default obtendra el valor 999 si es que se llegase a llamar de la siguiente manera
dim res=sumar(10,10)
msgbox res 'Da como resultado 1019 por el valor de Num3 q se tomo el valor por default
ok gracias ya lo entendi . haora ya consegui un modulo mejor donde ise un proyecto igual q el editor de registro . saludos