home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
tool
/
various
/
vbptr
/
vbsourc.txt
< prev
Wrap
Text File
|
1995-02-26
|
2KB
|
59 lines
DefInt A-Z
Declare Function GetDosEnvironment& Lib "Kernel" ()
'This is a Win API function that returns the length of a
'null-terminated string or LPSTR
Declare Function LStrLen Lib "Kernel" (ByVal LPSTR&)
'This function returns a VB string from a long pointer to
'a buffer which can be an LPSTR, or just a pointer to memory
Declare Function LP2Str$ Lib "VBPOINT.DLL" (LP As Any, ByVal pLen)
'This sub will copy bytes from one address to another
Declare Sub Str2LP Lib "VBPOINT.DLL" (SP As Any, DP As Any, ByVal nBytes)
Sub Command1_Click ()
MyPointer& = GetDosEnvironment&()
MyLen = LStrLen(MyPointer&)
Do
MyString$ = LP2Str$(ByVal MyPointer&, MyLen)
List1.AddItem MyString$
MyPointer& = MyPointer& + MyLen + 1
MyLen = LStrLen(MyPointer&)
Loop Until MyLen = 0
End Sub
Sub Command2_Click ()
Text$ = InputBox$("Enter an integer value to convert:", "Test MKI$ & CVI")
TestInt = Val(Text$)
rMKI$ = MKI$(TestInt)
lInt = Asc(Left$(rMKI$, 1))
rInt = Asc(Right$(rMKI$, 1))
Mess$ = "Chr$(" + Str$(lInt) + ") + Chr$ (" + Str$(rInt) + ")"
MsgBox Mess$, 0, "Converted to a string"
NewInt = CVI(rMKI$)
MsgBox Str$(NewInt), 0, "And converted back..."
End Sub
Function CVI (IntStr$)
Str2LP ByVal IntStr$, Temp, 2
CVI = Temp
End Function
Function CVL (LongStr$) As Long
Str2LP ByVal LongStr$, Temp&, 4
CVL = Temp&
End Function
Function MKI$ (ShortInt)
MKI$ = LP2Str$(ShortInt, 2)
End Function
Function MKL$ (LongInt&)
MKL$ = LP2Str$(LongInt&, 4)
End Function