home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 2000-05-04 | 3.7 KB | 112 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "VBCOMObject"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- '
- ' VBCOMObject
- '
- ' (C) Copyright 1995 - 1999 Microsoft Corporation. All rights reserved.
- '
- '
- Option Explicit
- '
- 'This function will illustrate the use of Variant BSTR types passed by Value.
- 'The String passed as a parameter is checked to be equal to 'test', and if so
- 'returns the value of 99, else returns 77. The parameter is also modified before
- 'the funtion returns.
- '
- Public Function processStringByVal(ByVal str)
- Dim value As Integer
- If str = "test" Then
- value = 99
- Else: value = 77
- End If
- str = "in VB -> processStringByVal!"
- processStringByVal = value
- End Function
- '
- 'This function will illustrate the use of Variant BSTR types passed by Reference.
- 'The String passed as a parameter is checked to be equal to 'test', and if so
- 'returns the value of 39, else returns 12. The parameter is also modified before
- 'the funtion returns.
- '
- Public Function processStringByRef(ByRef str)
- Dim value As Integer
- If str = "test" Then
- value = 39
- Else: value = 12
- End If
- str = "in VB -> processStringByRef!"
- processStringByRef = value
- End Function
- '
- 'Attempts to simulate passing an object, or null to a function. The return value
- 'from this function will either be a String stating that a Null was passed, or
- 'a String containing a description of the type of Object that was passed. Note:
- 'This method will only work if the Object passed is a known Variant type. The
- 'Object used as a parameter is also assigned the return value in this pass by
- 'value example.
- '
- Public Function processObjectByVal(ByVal val)
- Dim value As String
- If val = Null Then
- value = "Null was passed to the function processNullByVal"
- Else: value = "You passed in a " & TypeName(val)
- End If
- val = value
- processObjectByVal = value
- End Function
- '
- 'Attempts to simulate passing an object, or null to a function. The return value
- 'from this function will either be a String stating that a Null was passed, or
- 'a String containing a description of the type of Object that was passed. Note:
- 'This method will only work if the Object passed is a known Variant type. The
- 'Object used as a parameter is also assigned the return value in this pass by
- 'reference example.
- '
- Public Function processObjectByRef(ByRef val)
- Dim value As String
- If val = Null Then
- value = "Null was passed to the function processNullByRef"
- Else: value = "You passed in a " & TypeName(val)
- End If
- val = value
- processObjectByRef = value
- End Function
- '
- 'This Section deals with passing SafeArrays of Objects, ints, chars and Strings
- '
- '
- ' Takes an Object Array and Returns a String Array
- '
- Public Function processObjectArray(ParamArray objar())
- Dim result(10)
- Dim i As Integer
- For i = LBound(objar) To UBound(objar)
- result(i) = " Param type is " & TypeName(objar(i))
- objar(i) = "modified in processObjectArray"
- Next i
- processObjectArray = result
- End Function
- '
- ' Takes a String array and and returns an integer Array
- '
- Public Function processStringArray(ParamArray strarr())
- Dim result(10)
- Dim i As Integer
- For i = LBound(strarr) To UBound(strarr)
- result(i) = i
- strarr(i) = "Modifying the param in processStringArray"
- Next i
- processStringArray = result
- End Function
-