I have a dll which is registered in GAC and declared in my form. I am using Notes 9 and windows 7. The declaration -
Declare Function CreateAccount Lib
"c:\Program Files (x86)\PwC\SDCADInstall\SDCADLib.dll" (sADServer As
String , sUserID As String ,sPassword As String , sRoot As String,
sLocation As String , sLoS As String , sSBU As String , sFName As
String, sLName As String , sADId As String , sDescription As String
, sOffice As String ) As String
I am getting "Cannot create automation object" error while creating the object. The parameter values are collected by another function. Pl find the code below :
Dim obj As Variant
enter code here
Set obj = CreateObject("SDCADLib.Account")
retval = obj.CreateAccount(sADServer , sUserID ,sPassword , sRoot, sLocation , sLoS , sSBU , sFName, sLName , sADId , sDescription , sOffice )
CreateADAccount = retval
I am stuck here for ages. Please help.
I'm a bit confused because you include a Lib declaration, which is not necessary if you are using CreateObject to access your DLL from LotusScript via COM.
Since you mention the GAC, I presume you have written your DLL as a .NET assembly. Have you seen this IBM Technote about calling .NET classes from LotusScript and followed the instructions there? Specifically, have you followed the instruction that tells you that you have to run regasm in order to publish your DLL via COM. Without that, CreateObject won't find it.
Related
I'm trying to match an obtained property from one class with another class's same property at run time. After some research, I found out that there is such thing as "Reflection" in .net but Im using just VBA. Just for background: I'm automating an application using this code, so some objects are exposed, while others are not.
The way I'm currently doing it is using a property of obtained class "Description", and use that to search for the same property at the targeted class.
Set TargetVar = hySetOperations.Item(j).TargetVariable 'This is a RealVariable a property that refers to a class
Set SourceObj =hySetOperations.Item(j).SourceObject 'This is also a RealVariable
'In order to import variable from source object, we r gonna use TargetVariable description and truncate space, and use it (This might not work if description
'is different than actual name of the variable)
Dim RealVarString As String
RealVarString = TargetVar.Description
'Trim spaces
RealVarString = Replace (RealVarString, " ", "")
Set SourceVar = CallByName ( SourceObj, RealVarString, vbGet)
This actually works for most of the cases since "description" is usually the same as property's name, but with spaces. However, in some cases, this is not the case, in which things go south.
I fill the value of a specific notes document in a variable which has the data type VARIANT.
Reason: The value includes a backslash, letter and numbers.
Later in my code, I would like to build a database connections with this variable. Unfortunately it always fails with the following message:
Type mismatch in method CoerceString: Unkown found, Unkown expected
My code:
Dim varMailFile As Variant
Dim varMailServer As Variant
Dim maildb As New NotesDatabase( "", "" )
Dim cprofile As NotesDocument
vMailFile = doc.GetItemValue( "MailFile" )
vMailServer = doc.GetItemValue( "MailServer" )
Call maildb.Open(vMailServer, vMailFile)
I have already try to define the varMailFile and varMailServer as String, but it stilld doesnt work.
It makes also hard to troubleshoot, because the error message is not telling you what it found and what it expects.
I hope you can help me. Thanks.
NotesDocument.GetItemValue always returns a variant, even if the item only contains one value. You need EITHER to assign the first value (Index = 0 because LotusScript is 0- based by default) to your variable or just use the first value in your call:
First possibility:
varMailFile = doc.GetItemValue( "MailFile" )(0)
varMailServer = doc.GetItemValue( "MailServer" )(0)
...
Call maildb.Open(varMailServer, varMailFile)
Second possibility
varMailFile = doc.GetItemValue( "MailFile" )
varMailServer = doc.GetItemValue( "MailServer" )
...
Call maildb.Open(varMailServer(0), varMailFile(0))
Visual Studio is giving me the following error when I submit and store in the database.
"string must be exactly one character long"
to try to resolve tried this but without success:
cmd.Parameters.Add("#nomeEmpresa", OleDb.OleDbType.Integer).Value = Convert.ToChar(cbxEmpresa.Text)
cmd.Parameters.Add("#nomeContacto", OleDb.OleDbType.Integer).Value = Convert.ToChar(txtNomeContacto.Text)
cmd.Parameters.Add("#apelidoContacto", OleDb.OleDbType.Integer).Value = Convert.ToChar(txtApelidoContacto.Text)
cmd.Parameters.Add("#funcao", OleDb.OleDbType.Integer).Value = Convert.ToChar(txtFuncao.Text)
how can I solve this problem?
If you look at the documentation of Convert.ToChar you could read
Converts the first character of a specified string to a Unicode
character. Namespace: System Assembly: mscorlib (in mscorlib.dll)
Syntax
public static char ToChar( string value )
valueType: System.String
A string of length 1.
That's the reason of your error.
However your code seems to be incorrect. If you want to pass Integer values types by your user to your sql you need to convert your input using something like Int32.TryParse(textbox.text)
Instead if you want to pass string values you need to change your parameter type to SqlDbType.NVarChar.
Convert.ToChar(string) requires that the string only contain a single character. You need to gaurrantee this for each of the strings before you call it, or manually select the first character from the string, or something similar.
Docs for Convert.ToChar(string), throws FormatException "The length of value is not 1."
http://msdn.microsoft.com/en-us/library/5f3ew98y(v=vs.110).aspx
In a Visual Basic 6.0 program, I have a string sTemp that I want to ensure does not contain a quotation mark. I have the line:
If sTemp.Contains("""") Then
But when I type the period after sTemp, I don't get anything from intellisense, and when I try to compile I get the following error:
Compile error:
Invalid qualifier
VB6 strings are not objects, so there are no methods on the string variable that you can call.
To test does the string contain quotes you need to use the InStr function i.e.
if InStr(sTemp, """") > 0 then ' string contains at least one double quote
Hope this helps
UPDATE This has nothing to do with the original question
William, I just thought of this, it is unrelated information that you may find useful.
There are many ways to shoot yourself in the foot with VB6.
Among the less obvious is the fact that
Dim myCollection as new Collection
will have side effects you could never imagine.
Never DIM something AS New CSomething
Dim your variable, then on a second line, assign it to a new object. Hope this helps.
Dim myCollection as Collection
Set myCollection = New Collection
Try if instr(sTemp, """") > 0 then
I'm building a calculator application, and I have a Form, with a TextBox called txtVisor, that has the property NumbersOnly = true. I want to get the content of it(that I already know: txtVisor.Text) and convert it into a Integer, to do multiply it by 12, then convert the result into a String to set the txtVisor.Text as the result of the operation. How could I do this?
PS: I'm using NSBasic 7.0
txtVisor.Text = cstr( cint(txtVisor.Text)*12 )
The current version is NS Basic/CE 8, which will make your life much easier when it comes time to deploy your app.