What does this array declaration mean? - vb6

code :
Public ArryProErrorCode() As String, TempArry
I don't know what TempArry means when declare ArryProErrorCode() array?
can anyone explain it?
thx

TempArray is another variable declared on the same line but because you did not specify its type, it is a Variant.
You can declare multiple variables on the same line e.g.
Dim var1 As String, var2 As String, var3 As Long

Related

Declaring VB6 DLL Functions with two Dimensional Array

I have these arrays:
Dim sInp(10) As String
Dim dInp(90) As Double
Dim sOut(500, 10) As String
Dim dOut(500, 100) As Double
Now I have to declare the following function:
Integer MyFunction(sInp, dInp, dOut, sOut)
How do I do that?
So far I have this Code:
Declare Function MyFunction Lib "C:\Path\To\My\dll.dll" (ByRef sInp() As String, ByRef dInp() As Double, ByRef dOut() As Double, ByRef sOut() As String): Integer
How do I make the last two params to multidimensional arrays?
I already did register the library and the IDE can find the function but I can't use it so I thought I have to declare it like this.
This is all of the documentation I got from the company:
Integer MyFunction(sInp, dInp, dOut, sOut )
sInp[10] (string type)
dInp[90] (double type)
sOut[500, 10] (string type) (The String are initialized as “”)
dOut[500, 100] (double type) (The value are initialized as -9999.99 )
If you say you registered the DLL with "regsvr32" and got a success message then it is an ActiveX DLL (a COM object) and as such you need to instantiate it as you do with any object. First you need to click Project -> References, look for the name of your DLL in the list and click the checkmark beside it. Then you can declare instances from it:
Dim ObjDLL as New WhateverTheDLLClassIsCalled
Then it should expose the "MyFunction" method and you should see its parameters:
Call ObjDll.MyFunction()
The "Declare Function MyFunction Lib" syntax is for regular DLLs that do not need to be registered.

How to look for _ in a string in a column and remove _ in SAS

I am trying to do an if statement where it finds all the observations in the column "CarBrands" that have an underscore _ in the string (it's a character), and if it has the _, then I want to remove it. How do I do this? Thanks.
You can use the FIND function to check if a string contains the underscore. Then with the COMPRESS function, you can remove the underscore.
For example;
data work.ds;
input mystring $;
datalines;
mytext
my_text
;
run;
data work.ds_1;
set work.ds;
if find(mystring,'_') > 0 then mystring = compress(mystring,'_');
else mystring = mystring;
run;
See also:
https://sasexamplecode.com/find-a-substring-in-sas/
https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&docsetVersion=9.4&locale=en

Get variable type (ADO Object or String) in ASP Classic?

I'm trying to write a function in ASP Classic that accepts a parameter; but the parameter can either be a String, or an ADODB.Command Object. How can the function determine which type the parameter is?
So...
Function myfunction( input )
If is_ADODBCommand( input ) Then
' do stuff to object'
ElseIf is_string( input ) Then
' do stuff to string'
End If
End Function
Basically, please tell me how to do is_ADODBCommand and is_string
You can use VarType for primitive types.
is_string = (VarType(input) = vbString)
For object types, you can use TypeName since VarType returns a generic type specifier vbObject which gives no clue about the object's kind.
is_ADODBCommand = (TypeName(input) = "Command")

Is Nothing type mismatch VB6

I tried everything, but everything gives me type mismatch:
Type UserType
...
End Type
Dim SomeArray() As UserType
...
If SomeArray() Is Nothing Then <do smth>
If SomeArray() Is Empty Then <do smth>
If SomeArray Is Nothing Then <do smth>
If SomeArray Is Empty Then <do smth>
I do want to know when in my array of user-defined type is no elements! Because I don't want to use additional variables if I can use VB6 possibilities.
I'll use
Erase SomeArray
when its size = 1 (UBound(SomeArray) = 1) and i want to remove last element.
WHAT I DO WRONG? XD
VB6 "Is Nothing" applies to objects, not VB6 arrays.
"Ubound(myarray)", or "Ubound - LBound" is the way to determine an array's current length in VB6.
FYI, using a VB6 Collection might be a much better for you.
Heh, I found an arse-way to solve this problem from VBForums "VB6 - Returning/Detecting Empty Arrays". B)
(L/UBound doesn't work with empty arrays - it returns out of range subscript. ;) )
So...
Private Declare Function ArrPtr Lib "msvbvm60" Alias "VarPtr" (Ptr() As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Public Function Peek(ByVal lPtr As Long) As Long
Call CopyMemory(Peek, ByVal lPtr, 4)
End Function
Remember declare your own variables BEFORE definition of this subroutines! Or it will cause some strange mistakes (VB suddenly replaced my Exit Sub statement with Exit Function!).
Then I used
If Peek(ArrPtr(SomeArray)) = 0 Then
MsgBox "Looks like empty array SomeArray() before ReDim ^_^"
End If
and
Erase SomeArray
If Peek(ArrPtr(SomeArray)) = 0 Then
MsgBox "Looks like empty array SomeArray() after Erase ^_^"
End If
and everything works fine!
Not very simple, but fine.
Thx everybody, I shall learn this chained list named Collection.
Especially thanks for VBForums, they are really geeked ones.

Passing a string in VBScript to a COM Function which expects a BSTR*

I calling a third-party COM function in my VBScript. The method signature is as follows:
HRESULT ParseXML ([in] BSTR *textIn,[in] VARIANT_BOOL *aValidateIn,[out, retval] MSXML2.IXMLDOMDocument2 **aXMLDocOut)
In my VBScript the following call gives back a type mismatch:
Dim someText
someText = "Hello"
Dim response
response = ParseXml(someText, False)
But passing in the string literal works fine:
Dim response
response = ParseXml("Hello", False)
Any ideas what I need to do on the VBScript side?
BSTR is already a pointer.
BSTR* is therefore a pointer to pointer.
That is, you are passing a string by reference (ByRef textIn As String).
When you pass a variable by reference, the types must match. someText is VARIANT.
If you were to pass just BSTR (ByVal textIn As String), VB would handle the conversion for you.
Any ideas what I need to do on the VBScript side?
If you are sure it's the script you want to fix, not the library, then trick VB into using a temp variable which will be passed by ref:
response = ParseXml((someText), False)
Did you really write ParseXml(somText, False) in your script? Then it is a typo; it should be someText.

Resources