Results 1 to 12 of 12

Thread: [RESOLVED] Having trouble saving fields from form2 into public strings

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    10

    Resolved [RESOLVED] Having trouble saving fields from form2 into public strings

    what is weird is that it is actually saving some of the strings but not all..i dont understand
    this is a xml reader i coded that turns the values into form fields..(works)
    problem is taking those form fields and placing them into public strings
    which is really weird because some of strings actually do return but some are blank


    For example msgbox(__IRCVersion) returns the value from a textbox in the form
    but msgbox(__AltNick) or msgbox(__Nick) does not...
    Code:
    Imports System
    Imports System.IO
    Imports System.Xml
    Imports System.Xml.Serialization
    Imports System.Text
    Imports WindowsApplication1.SettingsForm
    
    Public Module XmlReaderT
        Public Class BlueNexusConfig
            Public _PassportInfo As EmailInfo
            Public _CookieInfo As Cookies
            Public _Settings As UserSettings
        End Class
        Public Class EmailInfo
            Public _Email As String
            Public _Pswd As String
        End Class
        Public Class Cookies
            Public _GKPID As String
            Public _MSRegCookie As String
            Public _MSProfile As String
            Public _MSTicket As String
        End Class
        Public Class UserSettings
            Public _PassportAuth As Boolean
            Public _CustGKID As Boolean
            Public _GKID As String
            Public _Nick As String
            Public _AltNick As String
            Public _Ident As String
            Public _VersionReply As String
            Public _IRC7Version As String
            Public _FindsFirst As Boolean
            Public _findsMethodPP As Boolean
            Public _FindsIp As String
            Public _ChatIP As String
        End Class
        Public Sub ReadSettings(filename As String)
            Dim serializer As New XmlSerializer(GetType(BlueNexusConfig))
            Dim fs As New FileStream(filename, FileMode.Open)
            Dim bnx As New BlueNexusConfig
            bnx = CType(serializer.Deserialize(fs), BlueNexusConfig)
            SettingsForm.GKPID.Text = bnx._CookieInfo._GKPID
            SettingsForm.Ticket.Text = bnx._CookieInfo._MSTicket
            SettingsForm.Profile.Text = bnx._CookieInfo._MSProfile
            SettingsForm.MSRegCookie.Text = bnx._CookieInfo._MSRegCookie
            SettingsForm.email.Text = bnx._PassportInfo._Email
            SettingsForm.Password.Text = bnx._PassportInfo._Pswd
            SettingsForm.TextBox1.Text = bnx._Settings._Nick
            SettingsForm.AltNick.Text = bnx._Settings._AltNick
            SettingsForm.IDENT.Text = bnx._Settings._Ident
            SettingsForm.ChatIP.Text = bnx._Settings._ChatIP
            SettingsForm.FindsIP.Text = bnx._Settings._FindsIp
            SettingsForm.VersionReply.Text = bnx._Settings._VersionReply
            SettingsForm.MethodcPP.Checked = bnx._Settings._PassportAuth
            If bnx._Settings._PassportAuth = False Then
                SettingsForm.MethodcG.Checked = True
            End If
            SettingsForm.NetworkChFinds.Checked = bnx._Settings._FindsFirst
    
            If bnx._Settings._FindsFirst = False Then
                SettingsForm.NetworkChChat.Checked = True
            End If
            SettingsForm.CustGateCheck.Checked = bnx._Settings._CustGKID
            SettingsForm.CustGate.Text = bnx._Settings._GKID
            SettingsForm.IRCVERSION.Text = bnx._Settings._IRC7Version
            SettingsForm.FindsMcPP.Checked = bnx._Settings._findsMethodPP
            If bnx._Settings._findsMethodPP = False Then
                SettingsForm.FindsMcG.Checked = True
            End If
        End Sub
        Public __Email = SettingsForm.email.Text
        Public __Pswd = SettingsForm.Password.Text
        Public __GKPIDX = SettingsForm.GKPID.Text
        Public __MSProfile = SettingsForm.Profile.Text
        Public __MSRegCookie = SettingsForm.MSRegCookie.Text
        Public __MSTicket = SettingsForm.Ticket.Text
        Public __ChatIP = SettingsForm.ChatIP.Text
        Public __FindsIp = SettingsForm.FindsIP.Text
        Public __PassportAuth = SettingsForm.MethodcPP.Checked
        Public __CustGKID = SettingsForm.CustGateCheck.Checked
        Public __GKID = SettingsForm.CustGate.Text
        Public __Ident = SettingsForm.IDENT.Text
        Public __Nick = SettingsForm.TextBox1.Text
        Public __AltNick = SettingsForm.AltNick.Text
        Public __VersionReply = SettingsForm.VersionReply.Text
        Public __IRC7Version = SettingsForm.IRCVERSION.Text
        Public __FindsFirst = SettingsForm.NetworkChFinds.Checked
        Public __findsMethodPP = SettingsForm.FindsMcPP.Checked
    End Module
    any help would be appreciated..ive had help from here before..very greatful

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Having trouble saving fields from form2 into public strings

    Don't be using messageboxes to do the debugging. Put a breakpoint in the code and step through it. The messagebox HAS to happen too late. By the time that shows up, whatever is going to go wrong has already happened, which is why you are seeing the blanks. The reason they are blank is what you are concerned about, while the messagebox only shows that they are blank.

    It may be sufficient to put a breakpoint on this line (or just after that line, actually):

    bnx = CType(serializer.Deserialize(fs), BlueNexusConfig)

    and take a look at bnx after the line has executed. It's probably going to be wrong, as well, in which case you know that the serializing is not picking up some of the fields. You'll also be able to see which ones. XML serialization doesn't work automatically for some types, which may be the whole problem, but finding out which ones it didn't work for is a good first step.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    10

    Re: Having trouble saving fields from form2 into public strings

    ok well so far i have found that the ones that work are

    __ChatIP
    __FindsIP
    __GKID
    __IRC7Version


    and the rest do not
    __Email
    __Pswd
    __GKPIDX
    __MSProfile
    _MSRegCookie
    __MSTicket
    __PassportAuth
    ___Ident
    __Nick
    __AltNick
    ___VersionReply

    still cant tell what is going on..

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    10

    Re: Having trouble saving fields from form2 into public strings

    i checked through breakpoint all values are saved.. some are just not saving from the form

  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Having trouble saving fields from form2 into public strings

    Quote Originally Posted by Shaggy Hiker View Post
    Don't be using messageboxes to do the debugging.
    Been guilty of this a few times
    My Github - 1d3nt

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Having trouble saving fields from form2 into public strings

    That's not the set I would have expected. I don't see any pattern to those. It isn't one type in any way.

    However, I'm also not clear on exactly which step is failing. Are you saying that you have stepped through lines like this one:

    SettingsForm.Password.Text = bnx._PassportInfo._Pswd


    and they work, but then when you get to this line:

    Public __Pswd = SettingsForm.Password.Text

    the variable ends up blank? That would be quite interesting, but I'm not fully clear on where the failure is happening. If this line is working:

    SettingsForm.Password.Text = bnx._PassportInfo._Pswd

    then the reading isn't the problem. If the Password.Text is then empty moments later, that would suggest that something in the SettingsForm is being triggered, such as a TextChanged event which deletes the text. However, I'm not quite clear if I have the situation right.
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    10

    Re: Having trouble saving fields from form2 into public strings

    yeah.. this is a real pain in the ass..all of the values update to the form..but i cannot seem to get them put into their own global variable..will have to try another method

  8. #8
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Having trouble saving fields from form2 into public strings

    Referring directly to specific Forms in a Module? You deserve it to go wrong frankly! Horrible, horrible design. And what the heck is Imports WindowsApplication1.SettingsForm supposed to be about (especially since you then apparently forget you did it later in the code)?!

    In any case, if you have the values in Textboxes what the heck do you need variables for anyway? The whole thing lacks logic.

    As far as I can see the main problem is that you're assigning global variables with values that depend on external initialisations that may not have actually taken place. Having the declarations at the bottom of the code does not mean that they will be executed after the Subs that precede them. Variables declared in a module should only be initialised with values if said values are literal ( = 9, = "some stuff") in my opinion. To do otherwise is simply flirting with trouble.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    10

    Re: Having trouble saving fields from form2 into public strings

    yeah..figured passed that bit..thought i would in fact use the form instead of the variables..but then found that i couldnt see those form values through the thread i wanted...dont know what do really

  10. #10

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    10

    Re: Having trouble saving fields from form2 into public strings

    OK GUYS ..thanks for everyones help i have figured this out
    http://www.vbdotnetforums.com/vb-net...arameters.html

    i now can see values from my settings window passed to the alternate thread..hope this helps

  11. #11
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Having trouble saving fields from form2 into public strings

    From this and your other thread it looks very like you leapt into this project without having truly thought out exactly what was to be achieved and how that translated into discrete tasks. I very much doubt that the secondary thread you speak of is truly required, for example, and even if it is you clearly have insufficient knowledge of the relationship of threads to UI controls and variables. And a module is without question the wrong way to go about this particular task!

    Frankly I'd recommend that you go back to the drawing board and really put some effort into the planning stage. When you've identified those areas in which your knowledge needs improving you should also get hold of some appropriate tutorials to work through before you so much as code another line. At the moment you're in a hole and still digging and gathering workarounds for problems of your own making really isn't going to progress you in any way.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: [RESOLVED] Having trouble saving fields from form2 into public strings

    Also, as I noted in the other thread, since you are using the default instance of the form, if you try to access the default instance from a second thread, you will get a different instance of the form. That's quite likely why things are appearing to be empty.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width