|
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)
|
|
|
|
|
Apart from anything that others might mention, and assuming it is not another typo
this line:
dim frmChamber as new frmChamber <======== problem line
frmChamber.show()
is trying to create a member with the same name as the class.
I'm essentially a C# chap but I think you might do better with this:
dim _frmChamber as new frmChamber <======== Note underscore added, ditto on line below
_frmChamber.show()
[Edit]
Incidentally I hate the use of underscores in member names, but I see this in a lot of the VB.Net posts, so I used it here. If there are better VB naming conventions, use one of those.
[/Edit]
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.”
|
|
|
|
|
Thanks,
I think I found the problem. As part of my learning curve I added control to a form (a label). I then tried to rename it and got an error as it had apparently figured out that I had actually declared it in my code.
I thought I then deleted it but after chasing this down for a bit I found that on the design view that the control re-appeared under a different name. I just deleted it and it works again.
bug in Visual studio?
No-e
|
|
|
|
|
Don't know about a specific bug, but the Designer can get screwed from time to time, by things like that.
Anyway, good luck!
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.”
|
|
|
|
|
I'm reading from a DBF file and get the string "ÒË╩ßÊÒÃ╩ ╩▀Ýݦ".
This string should be converted to look like "مستلزمات تكييف" (arabic - cp 1256)
Is there a way to do this? Maybe encoding.convert or something like that ...
I'm using VB.NET 2008
Thanks in advance ...
Marco
|
|
|
|
|
Hi,
you will need an Encoding object; try new Encoding(1256).
Assuming you have correct bytes in an array, the string should be returned by encoding.GetString(bytes).
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.
|
|
|
|