|
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.
|
|
|
|
|
Hi,
I tried this:
Dim asciiString As String = "ÒË╩ßÊÒÃ╩ ╩▀Ýݦ"
Dim [unicode] As Encoding = Encoding.Unicode
Dim en As EncodingInfo() = Encoding.GetEncodings()
For Each ei As EncodingInfo In en
Dim enc As Encoding = Encoding.GetEncoding(ei.CodePage)
Dim asciiBytes As Byte() = enc.GetBytes(asciiString)
Dim unicodeBytes As Byte() = Encoding.Convert(enc, [unicode], asciiBytes)
Dim unicodeChars([unicode].GetCharCount(unicodeBytes, 0, unicodeBytes.Length) - 1) As Char
[unicode].GetChars(unicodeBytes, 0, unicodeBytes.Length, unicodeChars, 0)
Dim unicodeString As New String(unicodeChars)
Console.WriteLine("Codepage: {0}", ei.CodePage.ToString())
Console.WriteLine("Unicode string: {0}", unicodeString)
Console.WriteLine("")
Next
But no used encoding creates the string I want.
Am I doing anything wrong?
Marco
|
|
|
|
|
Hi,
I don't know, maybe your original data does not contain the right bytes?
I don't think you can hide a Unicode string in an ASCII string, if you want to keep a valid unicode string, you must store it as one. Not sure if/how a DBF file does that. You may want to ask your questions in the database forum.
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.
|
|
|
|
|
pls how can i create xml root node in this format using vb.net dom
<digital_report xmlns:xsi="http://me.org/xmlschemainstance" xsi:="" nonamespaceschemalocation="sdp_schema_010.xsd">
|
|
|
|
|
|
The html monster has been cut loose again...
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.
|
|
|
|
|
i have this cde
dim doc as New XmlDocument
Dim declarationNode As XmlNode = doc.CreateXmlDeclaration("1.0", "", "")
doc.AppendChild(declarationNode)
Dim reportNode As XmlNode = doc.CreateElement("REPORT")
Dim att As XmlAttribute = doc.CreateAttribute("xmlns:xsi")
att.Value = "http://www.w3.org/2001/XMLSchema-instance"
reportNode.Attributes.Append(att)
Dim att1 As XmlAttribute = doc.CreateAttribute("xsi:noNamespaceSchemaLocation")
att1.Value = "SCHEMA_010.xsd"
reportNode.Attributes.Append(att1)
i recieved
<report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" nonamespaceschemalocation="SCHEMA_010.xsd">;
instead of
<report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="SCHEMA_010.xsd">;
why is it trncating
xsi:noNamespaceSchemaLocation to noNamespaceSchemaLocation
|
|
|
|
|
Your second attribute declaration is wrong.
Ebube wrote: Dim att1 As XmlAttribute = doc.CreateAttribute("xsi:noNamespaceSchemaLocation")
att1.Value = "SCHEMA_010.xsd"
reportNode.Attributes.Append(att1)
You should have :
Dim att1 As XmlAttribute = doc.CreateAttribute("xsi:noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance")
att1.Value = "SCHEMA_010.xsd"
reportNode.Attributes.Append(att1)
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
i try it and get
PENCOM_REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" d1p1:noNamespaceSchemaLocation="PFC_SCHEMA_010.xsd">
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
if i comment out att
i get
<PENCOM_REPORT xsi:noNamespaceSchemaLocation="PFC_SCHEMA_010.xsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
but want i need is
<PENCOM_REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PFC_SCHEMA_010.xsd">;
|
|
|
|
|
You must have a typo somewhere.
Here is the full code snippet, as based on your code. It works and generates the output you require.
Dim doc As New System.Xml.XmlDocument()
Dim declarationNode As System.Xml.XmlNode = doc.CreateXmlDeclaration("1.0", "", "")
doc.AppendChild(declarationNode)
Dim reportNode As System.Xml.XmlNode = doc.CreateElement("PENCOM_REPORT")
Dim att As System.Xml.XmlAttribute = doc.CreateAttribute("xmlns:xsi")
att.Value = "http://www.w3.org/2001/XMLSchema-instance"
reportNode.Attributes.Append(att)
Dim att1 As System.Xml.XmlAttribute = doc.CreateAttribute("xsi:noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance")
att1.Value = "SCHEMA_010.xsd"
reportNode.Attributes.Append(att1)
doc.AppendChild(reportNode)
Dim XMLOutput As String = doc.OuterXml
Resulting string XMLOutput is
<?xml version="1.0"?><PENCOM_REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SCHEMA_010.xsd" />
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
i cannot get same result still repeat <PENCOM_REPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" d1p1:noNamespaceSchemaLocation="PFC_SCHEMA_010.xsd">;
xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
|
Please post the exact code you are running. I can then assist you further.
The code snippet I posted does not have "d1p1" in it anywhere, so clearly you are running some different code.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
it worked. is a typo. Thanks
|
|
|
|
|
Hello ,
I am designing a VB application where i am forcing a machine shutdown using function as below.
Function InitiateSystemShutdown Lib "advapi32.dll"
But i found that the user can stop the forced shut down using the command "shutdown –a". So wanted a help as to how I can overcome this command and still force the shutdown.
Thanks in advance for the same.
Here in InitiateSystemShutdown function i am passing the forced parameter as true. still a user with admin rights on the m/c is able to abort the shut down.
|
|
|
|
|
Hi,
Following link might be useful.
http://www.dreamincode.net/code/snippet90.htm[^]
Personally I think its not a good idea to force shutdown on user for whatsoever reason.
Mithun Shitole
"Free Your Mind"
http://www.technoyaari.com
|
|
|
|
|
Thanks Mithun, but i wanted to know if the forced shut down has been initiated, the user should not be able to stop this by using "shutdown –a" command.
How to achieve this?
|
|
|
|