miketonny
asked on
help convert pascal to vba
Hi experts,
could i get following pascal code convert to vba version please? i know most of them but some of them like arrays i'm not sure how to do the correct conversion. any help would be great.
could i get following pascal code convert to vba version please? i know most of them but some of them like arrays i'm not sure how to do the correct conversion. any help would be great.
procedure TForm1.Button3Click(Sender: TObject);
// declare the variables. Note the use of 0-based Array of Chars for the PChars at the required length.
var
pControlPath : Array[0..MAX_PATH] of Char;
pIsAccessDB : Boolean;
pControlServer : Array[0..256] of Char;
pSQLName : Array[0..31] of Char;
pSQLPassword : Array[0..31] of Char;
pError : Array[0..2049] of Char;
begin
try
mmControl.Clear; // clear the display control
if not GetControlInformation(pControlPath, pIsAccessDB,
pControlServer, pSQLName, pSQLPassword, pError) then // get the results from the dll
mmControl.Lines.Add(pError) // if it fails display the error
else
begin
mmControl.Lines.Add('ControlPath: '+pControlPath); //show the control path
if pIsAccessDB then // show whether it's Access or SQL
mmControl.Lines.Add('Using an Access Control DB')
else
mmControl.Lines.Add('Using an SQL Control DB');
mmControl.Lines.Add('ControlServer: '+pControlServer); // show the Control server (SQL only)
mmControl.Lines.Add('UserName: '+pSQLName); //
mmControl.Lines.Add('Password: '+pSQLPassword); //
end;
except on E : Exception do
showMessage(E.Message);
end;
end;
ASKER
it's trying to connect to database , i'm just copying these codes directly from an sdk provided by an accounting software. it's purpose is to allow 3rd party programs to work with the software.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
not really, i'm just trying to estalibsh a connection to db and call a function from a reference. function name is "GetControlInformation", its in a .DLL, the purpose of this function is to return me whether connection is successful or not, that's all it does
So is mmControl the class used to work with the DLL?
Where is GetControlInformation()?
Where is GetControlInformation()?
ASKER
function GetControlInformation(pControlPath : PChar;
var pIsAccessDB : Boolean;
pControlServer : PChar;
pSQLName : PChar;
pSQLPassword : PChar;
pError : PChar): Boolean;
this is the function , its called from .DLL yes mmControl is the control working with the DLL
"PCHAR" is a buffer here
If you are going to use static arrays then you can just go ahead and set the array bounds.
Dim pControlPath (0 To MAX_PATH) as String
Dim pIsAccessDB as Boolean
Dim pControlServer (0 TO 256) as String
Dim pSQLName (0 To 31) as String
Dim pSQLPassword (0 To 31) as String
Dim pError (0 To 2049) as String
If you want Dynamic Arrays, then just leave out what is between the parenthesis and use ReDim Preserve as needed.
Dim pControlPath () as String
Dim pIsAccessDB as Boolean
Dim pControlServer () as String
Dim pSQLName () as String
Dim pSQLPassword () as String
Dim pError () as String
Also, you stated VBA in your question, but have VB.Net as a selected zone. I have requested that Visual Basic be added as well since you might get better support there.
Dim pControlPath (0 To MAX_PATH) as String
Dim pIsAccessDB as Boolean
Dim pControlServer (0 TO 256) as String
Dim pSQLName (0 To 31) as String
Dim pSQLPassword (0 To 31) as String
Dim pError (0 To 2049) as String
If you want Dynamic Arrays, then just leave out what is between the parenthesis and use ReDim Preserve as needed.
Dim pControlPath () as String
Dim pIsAccessDB as Boolean
Dim pControlServer () as String
Dim pSQLName () as String
Dim pSQLPassword () as String
Dim pError () as String
Also, you stated VBA in your question, but have VB.Net as a selected zone. I have requested that Visual Basic be added as well since you might get better support there.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There might be other and possible better ways to accomplish the desired results in VBA.