Thomas@RamonMuchoSiempre.SI
No entiendo... ***** ¬¬"
Notas: soy de México no entiendo otras culturas... ¬¬"
Dulces Lunas!¡.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
If SafeArrayAccessData(VarPtr(VarVariant), pData) = 0 Then
Private Type SafeArrayReader
cDims As Integer ' nr of dimensions for the array
fFeatures As Integer ' extra information about the array contents
cbElements As Long ' nr of bytes per array element. Possible Examples: 1=byte,2=integer,4=long,8=currency
cLocks As Long ' nr of times array was locked w/o being unlocked
pvData As Long ' address to 1st array item, can be a pointer to another structure/address
End Type
Dim VarVariant as variant
Dim VarVariantDest() as variant
Option Explicit
Option Base 0
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function SafeArrayAccessData Lib "Oleaut32" _
(ByVal psa As Long, pvData As Long) As Long
Private Declare Function SafeArrayUnaccessData Lib "Oleaut32" _
(ByVal psa As Long) As Long
' // msvbvm60.DLL
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" _
(Var() As Any) As Long
Private Sub Test_Translate()
Dim VarVariant As Variant
Dim VarVariantDest() As Variant
Dim aaa(0 To 3) As Variant
Dim psa As Long
Dim pData As Long
aaa(0) = "Miguel"
aaa(1) = "Angel"
aaa(2) = "Ortega"
aaa(3) = "Avila"
VarVariant = aaa
ReDim Preserve VarVariantDest(0 To 7)
CopyMemory psa, ByVal VarPtr(VarVariant)+8, 4
If SafeArrayAccessData(psa, pData) = 0 Then ' Bloqueo el Array y obtengo el puntero de varptr(VarVariant(0))
CopyMemory VarVariantDest(4), ByVal pData, 4 * 16 ' Copio el Contenido
SafeArrayUnaccessData psa ' Desbloqueo el array
End If
For psa = LBound(VarVariantDest) To UBound(VarVariantDest)
Debug.Print psa, VarVariantDest(psa)
Next psa
End Sub
Private Sub Form_Load()
Dim i As Byte
For i = 1 To 10
Call Test_Translate
MsgBox "Prueba: " & i
Next i
End Sub
Cita de: petro_boca en 23 Agosto 2010, 12:08 PM
http://galaxiagamer.esforos.com/tutorial-visor-de-tu-ip-t1563
Option Explicit
Public WithEvents CmbBox As ComboBox
Public StrToVerific As String
Public StrExplicit As Boolean
Private SwitchErr As Boolean
Event ErrorSel()
Private Sub CmbBox_click()
Dim CmbBox_Index As Long
Dim LenV As Long
If SwitchErr = False Then SwitchErr = Not SwitchErr: Exit Sub
With CmbBox
LenV = Len(StrToVerific)
If LenV <= 0 Then Exit Sub
For CmbBox_Index = .ListIndex To 1 Step -1
If Len(.List(CmbBox_Index)) >= LenV Then
If StrComp(Left$(.List(CmbBox_Index), Len(StrToVerific)), StrToVerific, Abs(Not StrExplicit)) = 0 Then
' CmbBox.Text = .List(CmbBox_Index)
.ListIndex = CmbBox_Index ' // "es lo mismo que la linea de arriba" solo que rehubica el item seleccionado
Exit For
End If
End If
Next CmbBox_Index
If CmbBox_Index <= 0 Then RaiseEvent ErrorSel
End With
End Sub
Option Explicit
Private WithEvents ClsCmbBox As Cls_CmbBox
Private Sub ClsCmbBox_ErrorSel()
Caption = "Error"
End Sub
Private Sub Combo1_Click()
Caption = Combo1.Text
End Sub
Private Sub Form_Load()
Set ClsCmbBox = New Cls_CmbBox
With ClsCmbBox
Set .CmbBox = Combo1
.StrExplicit = True
.StrToVerific = "----"
End With
Combo1.AddItem ("Miguel")
Combo1.AddItem ("Angel")
Combo1.AddItem ("Ortega")
Combo1.AddItem ("Avila")
Combo1.AddItem ("----comidas----")
Combo1.AddItem ("pizza")
Combo1.AddItem ("pollo")
Combo1.AddItem ("choripan")
Combo1.AddItem ("----bebidas----")
Combo1.AddItem ("agua")
Combo1.AddItem ("cerveza")
Combo1.AddItem ("gaseosa")
Combo1.AddItem ("vino")
Combo1.ListIndex = 0
End Sub