• Welcome to Valhalla Legends Archive.
 

Cast from string...? [VB.NET]

Started by CrAz3D, October 11, 2004, 07:05 PM

Previous topic - Next topic

CrAz3D

On Error GoTo ih
                    ML(UBound(ML)).UsernameFROM = Username
                    Form1.GlobalForm.Chat(True, True, System.Drawing.Color.Azure, "usernamefrom added")
                    ML(UBound(ML)).UsernameTO = cMD(0)
                    Form1.GlobalForm.Chat(True, True, System.Drawing.Color.BurlyWood, "usernameto added")
                    ML(UBound(ML)).Message = str.Right(pA(1), Len(pA(1)) - cMD(0))
                    Form1.GlobalForm.Chat(True, True, System.Drawing.Color.CadetBlue, "message added")
                    ML(UBound(ML)).Time = System.DateTime.Now
                    Form1.GlobalForm.Chat(True, True, System.Drawing.Color.DeepPink, "tiem added")
                    ReDim Preserve ML(UBound(ML) + 1)
                    SendW("Mail to " & cMD(0) & " added to delivery list")


All goes fine through UsernameTO =, after that I recieve the following error:
QuoteCast from string "craz3d[xl]" to type 'Double' is not valid

My original string was:
craz3d[xl] hi there dood
cMD(0) ends up being craz3d[xl]

My Mail Structure is:
    Public Structure MailList
        Public UsernameTO As String
        Public UsernameFROM As String
        Public Message As String
        Public Time As String
    End Structure
    Public ML() As MailList


Help is appreciated.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

CrAz3D

Oops, problem was a stupid thing.

Forgot to use then length function for cMD(0) when trying to set the message, my bad.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

MyndFyre

#2
Out of curiousity, why are you using "On Error Goto" in VB.NETVB.NET uses SEH (Structured Exception Handling), in which you should be using Try...Catch, Try...Finally, or Try...Catch...Finally blocks to handle errors.  Using On Error Goto is bad practice in VB.NET.

Another question: Why are you using a Structure and not a Class?  If you use a structure, references to the strings need to be duplicated, resulting in a reallocation of 16 bytes of memory for each duplication of a structure, whereas when you use a class, you'll only need to duplicate a reference to that class instance, costing only 4 bytes of memory.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

CrAz3D

Thank you, I will look into Try & Finally & Catch and also look at using classes instead of structures.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...