home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 6
/
Eagles_Nest_Mac_Collection_Disc_6.TOAST
/
Windows
/
VisBasAPIex
/
VBAPIGUIDE.image
/
DLLPARAM.ZIP
/
DLLPARAM.FRM
< prev
next >
Wrap
Text File
|
1994-01-23
|
10KB
|
387 lines
VERSION 2.00
Begin Form dllparam
Caption = "DLL parameter tester"
ClientHeight = 4740
ClientLeft = 1095
ClientTop = 1485
ClientWidth = 7365
Height = 5145
Left = 1035
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 4740
ScaleWidth = 7365
Top = 1140
Width = 7485
Begin CommandButton Command3
Caption = "Variant"
Height = 375
Left = 3180
TabIndex = 21
Top = 4200
Width = 1275
End
Begin CommandButton Command2
Caption = "VariantByVal"
Height = 375
Left = 1740
TabIndex = 20
Top = 4200
Width = 1335
End
Begin CommandButton Command1
Caption = "VBArray"
Height = 375
Left = 240
TabIndex = 19
Top = 4200
Width = 1335
End
Begin CommandButton TestIntByval
Caption = "ReceivesInteger(5)"
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 2175
End
Begin CommandButton TestIntByref
Caption = "Add5To5"
Height = 375
Left = 2640
TabIndex = 4
Top = 240
Width = 1575
End
Begin CommandButton TestControl
Caption = "Get Hwnds"
Height = 375
Left = 4560
TabIndex = 10
Top = 240
Width = 1215
End
Begin CommandButton TestLongByval
Caption = "ReceivesLong(6)"
Height = 375
Left = 240
TabIndex = 1
Top = 720
Width = 2175
End
Begin CommandButton TestLongByref
Caption = "Add5To6"
Height = 375
Left = 2640
TabIndex = 5
Top = 720
Width = 1575
End
Begin CommandButton TestSingleByval
Caption = "ReceivesSingle(1.59)"
Height = 375
Left = 240
TabIndex = 2
Top = 1200
Width = 2175
End
Begin CommandButton TestSingleByref
Caption = "Add5To1.59"
Height = 375
Left = 2640
TabIndex = 6
Top = 1200
Width = 1575
End
Begin CommandButton TestCurrencyByval
Caption = "ReceivesCurrency(1.2345)"
Height = 375
Left = 4440
TabIndex = 15
Top = 1200
Width = 2775
End
Begin CommandButton TestDoubleByval
Caption = "ReceivesDouble(3.145)"
Height = 375
Left = 240
TabIndex = 3
Top = 1680
Width = 2175
End
Begin CommandButton TestDoubleByref
Caption = "Add5To3.145"
Height = 375
Left = 2640
TabIndex = 7
Top = 1680
Width = 1575
End
Begin CommandButton TestCurrencyByref
Caption = "AddPennyToCurrency(1.23)"
Height = 375
Left = 4440
TabIndex = 16
Top = 1680
Width = 2775
End
Begin CommandButton TestString
Caption = "ReceivesString ""Hello"""
Height = 375
Left = 240
TabIndex = 8
Top = 2160
Width = 2175
End
Begin CommandButton TestStringChange
Caption = "Adds'!'to""Hello"""
Height = 375
Left = 2640
TabIndex = 9
Top = 2160
Width = 1575
End
Begin CommandButton TestVBString
Caption = "ReceivesVBString(""String to DLL"")"
Height = 375
Left = 240
TabIndex = 11
Top = 2760
Width = 3375
End
Begin CommandButton TestUserType
Caption = "ReceivesUserType(1,2,3,4)"
Height = 375
Left = 3720
TabIndex = 14
Top = 2760
Width = 3495
End
Begin CommandButton TestVBStringChange
Caption = "ChangesVBString(""Short"")"
Height = 375
Left = 240
TabIndex = 12
Top = 3240
Width = 3375
End
Begin CommandButton TestAddUserString
Caption = "AddUserString"
Height = 375
Left = 3720
TabIndex = 18
Top = 3240
Width = 1695
End
Begin CommandButton ReceivesIntArray
Caption = "Int Array"
Height = 375
Left = 5520
TabIndex = 17
Top = 3240
Width = 1695
End
Begin CommandButton ReturnVBString
Caption = "ReturnsVBString()"
Height = 375
Left = 240
TabIndex = 13
Top = 3720
Width = 3375
End
End
' DLL parameter test program
' Copyright (c) 1992, by Desaware
' All rights reserved
'
'
' This program is used to test the dllparam.dll dynamic
' link library.
Sub Command1_Click ()
ReDim x(5) As Integer
Dim y%
x(0) = 0
x(1) = 1
x(2) = 2
x(3) = 3
x(4) = 4
y% = ReceivesVBArray(x())
End Sub
Sub Command2_Click ()
Dim v As Variant
Dim res%
v = "hello"
res% = ReceivesVariantByVal(v)
End Sub
Sub Command3_Click ()
Dim v As Variant
Dim res%
v = "hello"
v = ReceivesVariant(v)
MsgBox "V is " + v
End Sub
' This is a test of passing a pointer to a numeric array
' Note the unique DLL call
'
Sub ReceivesIntArray_Click ()
ReDim x(4) As Integer
Dim u As UserType
x(0) = 1
x(1) = 3
x(2) = 9
x(3) = 81
' Pass a pointer to the first element of the array.
' The DLL has no way of knowing how long the array is
' unless you define a length parameter for the function.
ReceivesIntArray x(0)
u.e(0) = 1
u.e(1) = 2
u.e(2) = 3
u.e(3) = 4
ReceivesIntArray (u.e(0))
End Sub
' A DLL function returning a Visual Basic String
Sub ReturnVBString_Click ()
a$ = ReturnsVBString()
MsgBox a$, 0, "ReturnsVBString"
End Sub
' Show how to access strings inside user defined types
Sub TestAddUserString_Click ()
Dim u As UserType
' Note - this is call by reference, the DLL can change
' the value of u
u.s = "orignal string"
AddUserString u
MsgBox u.s, 0, "String in usertype changed"
End Sub
' Passing controls and forms as parameters
Sub TestControl_Click ()
hctl% = GetControlHwnd(TestControl)
hfrm% = GetFormHwnd(dllparam)
MsgBox "This control hwnd is " + Str$(hctl%) + ", the form hwnd is " + Str$(hfrm%), 0, "Get Hwnds"
End Sub
' Passing currency by reference
Sub TestCurrencyByref_Click ()
Dim c@
c@ = 1.23
AddPennyToCurrency c@
MsgBox Str$(c@), 0, "AddPennyToCurrency"
End Sub
' Passing currency by value and returning currency
Sub TestCurrencyByval_Click ()
Dim c@
c = 1.2345
c = ReceivesCurrency(c)
End Sub
' Passing doubles by reference
Sub TestDoubleByref_Click ()
d# = 3.145
Add5ToDouble d#
MsgBox Str$(d#), 0, "Add5ToDouble"
End Sub
' Passing doubles by value and returning doubles
Sub TestDoubleByval_Click ()
d# = ReceivesDouble(3.145)
End Sub
' Passing integers by reference
Sub TestIntByref_Click ()
x% = 5
Add5ToInteger x%
MsgBox Str$(x%), 0, "Add5ToInteger"
End Sub
' Passing integers by value and returning integers
Sub TestIntByval_Click ()
x% = ReceivesInteger(5)
End Sub
' Passing longs by reference
Sub TestLongByref_Click ()
y& = 6
Add5ToLong y&
MsgBox Str$(y&), 0, "Add5ToLong"
End Sub
' Passing longs by value and returning longs
Sub TestLongByval_Click ()
y& = ReceivesLong(6)
End Sub
' Passing singles by reference
Sub TestSingleByref_Click ()
f! = 1.59
Add5ToSingle f!
MsgBox Str$(f!), 0, "Add5ToSingle"
End Sub
' Passing singles by value and returning singles
Sub TestSingleByval_Click ()
f! = ReceivesSingle(1.59)
End Sub
' Passing strings (null terminated)
' Always by reference
Sub TestString_Click ()
ReceivesString "Hello"
End Sub
' Passing and modifying strings (null terminated)
' Always by reference
Sub TestStringChange_Click ()
' Null terminated string is passed to the routine
' x$ must be preinitialized to the maximum length.
' The DLL may change the contents of the string, but
' must never go past the null terminator
x$ = "Hello"
ChangesString x$
MsgBox x$, 0, "ChangesString"
End Sub
' Passing user defined types
' Always by reference
Sub TestUserType_Click ()
Dim u As UserType
u.a = 1
u.b = 2
u.c = 3
u.d = 4
u.e(0) = 5
u.e(1) = 6
u.e(2) = 7
u.e(3) = 8
' Note - this is call by reference, the DLL can change
' the value of u
ReceivesUserType u
End Sub
' Passing Visual Basic strings
Sub TestVBString_Click ()
ReceivesVBString "String to DLL"
End Sub
' Passing and modifying Visual Basic strings
' Note - no length restrictions apply
Sub TestVBStringChange_Click ()
a$ = "Short"
ChangesVBString a$
MsgBox a$, 0, "ChangesVBString"
End Sub