|
I am trying to use a com object in VB.NET (Visual Studio 2005). One of the input parameter of a com mehtod is of type Variant. I tried to pass an Object, it does not work (type mismatch).
What type should I use as the input paramter? How to get around this problem? Thank.
|
|
|
|
|
You need to decorate the parameter definition with the MarshalAs(UnmanagedType.Struct) attribute which is found in the System.Runtime.InteropServices namepsace. eg.
<DllImport("user32.dll")> _
Public Shared Function myFunction(<MarshalAs(UnmanagedType.Struct)>ByRef lpRect As Object) As Boolean
End Function
[Edit] Sorry, just noticed that the pre tags mangled my formatting and confused my attribute tags with html tags. Should make more sense now.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
modified on Wednesday, November 11, 2009 5:57 PM
|
|
|
|
|
Thanks. The information you provided is very helpful, although I do not have to use "VARIANT" for this project after all, because there is another method in the com object that can do the same thing without "VARIANT".
|
|
|
|
|
Hi,
I have VB project with Access Database
but when i use update statement with no errors but no changes occured in the database.
connection string statement is
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=App_Data\TrainingDept.mdb" & _
";Persist Security Info=True"
why?
|
|
|
|
|
|
yes.Where clause is correct and when i wrote update statement
on the access database, the data will be updated but the problem is the update statement in the vb code
|
|
|
|
|
What you posted looks ok, but its hard to tell just by that. The only thing i can offer with what you posted is if you are using 64 bit what you have won't work. ACE isn't supported in 64 bit.
Post the entire statement or better yet look into TableAdapters.
|
|
|
|
|
If you have your Access database in your project, it is possible that every time you compile and run the app, the database being used (in the Debug folder or your project) is being overwritten by the master copy of the database in the project. Any changes you make during one run of your program will be lost the next time you run the app from Visual Studio.
Now, if you're looking for changes that were supposed to have been made in one run of the application and you're not seeing them, the possible problems expand to either an incorrect WHERE clause in the SQL (it doesn't find the record(s) to change), or you're not looking at the correct copy of the database for the changes.
|
|
|
|
|
Do a SELECT with your UPDATE statement's WHERE clause and you should see the reason why your table is not updated.
|
|
|
|
|
|
|
Hi there,
I have the following code which takes data from SQL and then adds it to a Excel Spreadsheet.
This all works fine, but I need to subtract the column "K" from Column "L" and store it in "M"
It inserts the formula into the required number of rows (dependant of the value "R2") but the formula shows as =(K & D1)-(L & D1) in each cell and not for example =(K 28)-(L 28) etc....
Can you help??
Thanks
<code>
Dim SQlQuery2 As String = "select * from growth where Name <> '[Files]'order by FullPath"
Dim SQLCommand2 As New SqlCommand(SQlQuery2, myConn)
Dim SQlReader2 As SqlDataReader = SQLCommand2.ExecuteReader
Dim R2 As Integer = 27
While SQlReader2.Read
R2 = R2 + 1
osheet.Range("I" & R2).Value = SQlReader2.GetValue(0).ToString
osheet.Range("I" & R2).BorderAround(8)
osheet.Range("J" & R2).Value = SQlReader2.GetValue(1).ToString
osheet.Range("J" & R2).BorderAround(8)
osheet.Range("K" & R2).Value = SQlReader2.GetValue(2).ToString
osheet.Range("K" & R2).BorderAround(8)
osheet.Range("L" & R2).Value = SQlReader2.GetValue(3).ToString
osheet.Range("L" & R2).BorderAround(8)
End While
SQlReader2.Close()
SQlReader2 = Nothing
Dim D1 As Integer = 28
Do Until D1 = R2
osheet.Range("M" & D1).Formula = "=(""K"" & D1)-(""L"" & D1)"
D1 = D1 + 1
Loop
</code>
|
|
|
|
|
The below works, you just have to build the string, yours is a common issue. Everything in the formula should be in parenthesis, then go back and replace all numbers with " & D1 & "
osheet.Range("M" & D1).Formula = "=(K" & D1 & ")-(L" & D1 & ")"
|
|
|
|
|
Hi there,
Thats great, working fine now...
Ta v much.....
|
|
|
|
|
Good Day All
I created 2 batch files to run a command line program...the first runs the actual program and accepts in a parameter, and the second batch file runs the first batch file with the parameters I give it.
I now need to get some information from this process, the first is the time taken to complete the process, and the second is to get the memory used.
I am trying to create a VB console application (not sure if on the right track) to run the executable, the same way I did in the batch files (sending parameters to a command line program).
Getting the time taken is no problem. my problem is getting the VB console to call the executable (not sure how to do that), and the other problem is getting the amount of memory used running the VB program.
The memory used, is not so important at this point (I can work on that later). I would like to know if anyone could help me with running the executable within my newly created program.
Thanks in advance!
|
|
|
|
|
Look into the Process class (Process.Start("SomeApplication.exe") , Process.HasExited , Process.ExitTime , etc) to launch the app you want to monitor.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Thanks for the assistance. The first bit helped, now I just have to look into it in more depth to extract some further information from the process.
Thanks again!
|
|
|
|
|
Have a look at System.Diagnostics.Process class.
|
|
|
|
|
I will look into this. Thanks!
|
|
|
|
|
Hello.
The problem is this: I have two tables:
Requirements(ID_doc, Name_doc, ID_DeliveryType) and
DeliveryTypeCodeList(ID_DeliveryType, DeliveryType_doc).
I put the form fields from the table ‘Requirements’ where the column ‘ID_DeliveryType’ is ComboBox type-a. For ComboBox DataSource I put table ‘DeliveryTypeCodeList’ where column ‘DeliveryType_doc’ is DisplayMember and column ‘ID_DeliveryType’ column is ValueMemeber.
Requirements
--- ID_doc - Name_doc - ID_DeliveryType
________________________________________
-----1--------doc1----------23----------
-----2--------doc2----------23----------
-----3--------doc3-----------2----------
-----4--------doc4-----------3----------
DeliveryTypeCodeList
--- ID_DeliveryType - DeliveryType_doc
________________________________________
---------2--------------poste-----------
---------3---------------fax------------
--------23---------------mail-----------
My wish now is that when I run the program, in the ComboBox it print (descriptive)values from the column 'DeliveryType_doc' (mail, fax, post)!
But it just does not happen?!???
If you have time, there is also the source code of the program: http://rapidshare.com/files/305140006/BugComboBox.rar
or if you want you can see the video where I show that I have tried all combinations: http://www.youtube.com/watch?v=5VK-c39eL-4
THANK YOU!
|
|
|
|
|
Noone is going to download your entire project. You have to post the relevant code that sets up the ComboBox and do a better job of explaining what you want. I'm not entirely clear on what the problem is.
|
|
|
|
|
Watch the video http://www.youtube.com/watch?v=5VK-c39eL-4
and all will be clear.
By the way, there is no code associated with ComboBox.
|
|
|
|
|
Apart for not having any code in the project, the WHOLE thing is 160 KB, so why not download it and try what we did.
The project contains only the part that is relevant to the question, and a dummy database that is needed for it.
It contains no code, since we are trying to program the MS way: clicking, dragging and dropping components, without or at least with minimum code written by hand.
That is why we posted the video (11 MB) on the youtube, so people can see what we are trying to do.
So please, if you have an answer, do post it, otherwise, thank you for reading our question.
|
|
|
|
|
huamala wrote: so why not download it and try what we did.
Because I don't run code I do not trust.
You post the relevant code here in your post in PRE tags...
|
|
|
|
|
use Total Comander to see the files or you can look at the VIDEO.
|
|
|
|