coisa que eu sempre quis ser capaz de fazer com variaveis
um indireto com variaveis
var1=12
novo_valor =56
nome_var="var1"
varstr(nome_var,novo_valor)
agora o valor de var1 é 56
encontrei algumas respostas, mas infelizmente não consegui aplicar da maneira que eu quero
http://www.thevbzone.com/secrets.htm
http://www.linhadecodigo.com.br/artigo/ ... eiros.aspx
http://stackoverflow.com/questions/1632 ... nce-in-vba
http://vb.mvps.org/tips/varptr/
http://www.linhadecodigo.com.br/artigo/ ... byref.aspx
http://bytecomb.com/vba-internals-getting-pointers/
http://www.ufpa.br/heliton/arquivos/pro ... el_VBA.pdf
Private Declare Sub CopyAnyToMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As Long, ByRef Source As Any, ByVal Length As Long)
Private Declare Sub CopyMemoryToAny Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByVal Source As Long, ByVal Length As Long)
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare PtrSafe Sub FillMemory Lib "kernel32" Alias "RtlFillMemory" (Destination As Any, ByVal Length As Long, ByVal Fill As Byte)
Sub CopyArrayRef_Good()
Dim v1 As Variant, v2 As Variant
v1 = Array(1, 2, 3)
CopyMemory v2, v1, 16
v2(1) = "Hello"
Debug.Print Join(v1, ", ")
FillMemory v2, 16, 0 ' Clean up:
End Sub
Sub test()
Dim VarPointer As Long, intTarget As Long, intVar As Long
intVar = "53332"
intTarget = 1111
Nome_variavel = "intVar"
Debug.Print intVar, intTarget
varPointer3 = VarPtr(CStr(Nome_variavel)) + 36
CopyAnyToMemory varPointer3, intTarget, 4
intTarget = 32
Debug.Print intVar, intTarget
End Sub
eu estava querendo transformar em função mas não foi
Postado : 26/07/2016 11:58 pm