|
got it.
Thanks
Mithun Shitole
"Free Your Mind"
http://www.technoyaari.com
|
|
|
|
|
Hi.
i have 2 applications. one developed in c# and other in vb 6. vb application makes some changes to sql database. These changes need to be recorded in another database(used by c# code). Due to privilages on the databases, i need vb to call the c# exe and provide it with 2 arguments. That is, my vb code needs to call a C# exe and provide it with two arguments. C# application is a console application. is this possible in vb. If yes, some help would be greatly appreciated.
Thanx in advance
mark
|
|
|
|
|
I am not at all sure that you can call into a managed .EXE from VB6.
However, if C-like exports between VB6 and VB.Net[^] is correct you can call into a managed .dll. If you are able to separate the parts of your application to be called into a dll and apply the principles from the article to it, that might be a resolution to your problem.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
thanx for replying.
I went through the article you forwarded, and realized that it requires editing in IL. I also read some comments and other articles and am confused whether i should take this approach or not?
If you can provide some more help, i would be really greatfull . Thanx
|
|
|
|
|
Hi,
you probably could organize the C# app as a console app taking its parameters from the command line; and invoke it the way VB6 invokes all EXE files, through some magic function (system? ShellExecute? I don't recall).
FWIW: if the parameters become more complex, I tend to have the master EXE put them in a file, and pass the full filepath (which would contain numeric date and time to make it unique) as the single parameter to the slave EXE.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi,
Thanx for replying.
I have received a reply that points at the fact that "vb might not be able to call managed dll/exe". which is the case in .net. Do you still think that i should organize the C# application as console and invoke it using vb6 shell. Again, being a .net programmer, i would appreciate if u forward me a better link on system? ShellExecute? .
Thankyou again
|
|
|
|
|
|
.DLL:
do what Uncle said above to make the .dll support interop. Make sure you to use generic data types in your method signature. There are plenty of tutorials on this. Use regasm as nec on clients, etc.
.EXE:
You can start a .Net exe from VB6. For a simple example, all you have to do is something like:
strRunFilename = strRunFilename & " " & gstrCommandLineProgram
Shell strRunFilename, vbNormalFocus
Note that gstrCommandLineProgram get parsed from within the .Net .exe and the appropriate action(s) are taken. You could also use CreateProcessWithLogon, WaitForSingleObject, etc, etc depending on exactly what you need to do; but shell is easy and probably suffice for you what you're trying to do.
This is digging deep in the memory banks, but I think shell will work pretty much for any OS level where as CreateProcessWithLogon may have not worked with win98 (if there are OS requirements).
Cheers!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
OK, I am in the home stretch here, dynamic context menu over dynamic control arrays, for a guy new to .net. I have it all working except for one small, strange little thing. In my procedure to show the context menu, I thought I could just use the me.mouseposition. as follows:
Private Sub lblSlot_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
HandlePopup(sender, e) ' build my menu
Debug.Write(Me.MousePosition())
ContextMenu1.Show(Me, Me.MousePosition)
Debug.Write(Me.MousePosition())
End Sub
if I look at the output in the debug window pre and post clicking the mouse and seeing the popup, I will see something like the following: The menu does not pop up near where the mouse was.
{x=786, Y=476}{x=797, Y=687}
any idea what may be going on here?
No-e
|
|
|
|
|
Take a look at the following two properties PointToClient PointToScreen
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
What is the .Net equiv to this vb6 format:
Format(strCode, "@@-@@@@-@@")
Apparently my brain has stopped functioning today. Sigh.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
String.Format
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Thanks for the reply.
I've tried String.Format and MS.VB.Format without the results I expect. Is the @ character no longer supported?
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I think your problem is that the parameters have switched round, and yes it is no longer "@" it is now "{0}". See the MSDN Documentation[^]
Try :String.Format("{0}{0}-{0}{0}{0}{0}-{0}{0}", mycode)
If I understand correctly, if your code was "g" you want the result "gg-gggg-gg". .Net supports multiple replaces in the format string hence the use of "{0}"
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
If I understand correctly, if your code was "g" you want the result "gg-gggg-gg".
Correct on the desired output. I understand the string.format in regards to the {number} format, which is just a place holder for text. I just thought there would be something a little prettier than this type of scenario:
'To get a @@-@@@@-@@
Dim h As String = "23snfg33"
Dim result As String = String.Format("{0}{1}-{2}{3}{4}{5}-{6}{7}", h.Chars(0), h.Chars(1), h.Chars(2), h.Chars(3), h.Chars(4), h.Chars(5), h.Chars(6), h.Chars(7))
The format literals I have found deal directly with numeric or date outputs, not with just plain old character place holders.
No big whoop though, thanks for input.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Just to pretty it up a bit, you could do:
'To get a @@-@@@@-@@
Dim h As String = "23snfg33"
Dim result As String = String.Format("{0}-{1}-{2}", h.Substring(0, 2), h.Substring(2, 4), h.Substring(6, 2))
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
LOL, Tru-Dat!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I have a much better solution, having slept on it. Use a System.ComponentModel.MaskedTextProvider . To make it easier wrap it up in a Class. e.g.
Public Class MaskFormater
Private Sub New()
End Sub
Public Shared Function Format(ByVal input As String, ByVal mask As String) As String
Dim maskProvider As New System.ComponentModel.MaskedTextProvider(mask)
maskProvider.Add(input)
Return maskProvider.ToDisplayString()
End Function
End Class
This can then be used as follows:
'To get a @@-@@@@-@@
Dim h As String = "23snfg33"
Dim result As String = MaskFormater.Format(h, "aa-aaaa-aa")
For a list of available masking elements see the mask documentation on MSDN[^]">
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
I thought about having a maskedtextbox object do it for me, but this is for an import process in a .dll and thought it would be a "corny fix".
I think your suggestion is great and I was totally unaware about the MaskedTextProvider.
Thanks!
EDIT:
Just did some benchmarks with some slight modifications to your suggestion while iterating through several million string values. The maskedTextProvider method is over 6x faster than the substring! Doh!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
modified on Wednesday, June 17, 2009 12:47 PM
|
|
|
|
|
Not sure what I did here, I am new to .net and have been thrown into upgrading an app. I have a main form and a sub form and the upgrade wizard seemed to do a upgrade to teh form load and called "frmChamber.definstance.show().
This was all working very well as I moved on to other items. (working on controls and menus for that form) I think I got all that working but now I have trouble loading the form. All I changed the sub form is adding context menus and some text boxes to labels and such)
one of the first things the form does is open a comm port mcomm1.portopen = true , now I get an error "object reference set to an instance of an object" when I try to do that.
I get the same error when I do
dim frmChamber as new frmChamber
frmChamber.show()
I get the same error on the dim statement (before the show event)
what is the proper way to load a form? What am I doing wrong, this was working before....
the message is thrown on the line
Me.components = New System.ComponentModel.Container
in the InitializeComponent() section.
I load a different form before this one and it works fine...
no-e
modified on Tuesday, June 16, 2009 11:16 AM
|
|
|
|
|
No-e wrote: "object reference set to an instance of an object"
Hint: Something is nothing.
जय हिंद
modified on Tuesday, June 16, 2009 11:50 AM
|
|
|
|
|
Nothing in VB
|
|
|
|
|
Thanks for correcting.
जय हिंद
|
|
|
|
|
sorry, typo, error is "Object Reference not set to an instance of an object"
the error appears in the InitializeComponent
Me.components = New System.ComponentModel.Container
Is it possible a control I added to teh form could cause this? (I added a context menu and a label)
|
|
|
|