dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: saving/loading contol info

  1. #1
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    8

    saving/loading contol info

    Hi, I was wondering if anyone can please help me with creating some code to:

    1. Get the name of the form I am using (I use about 20 different forms in the program)?

    2. Write text containing info from Textboxes and Option button controls to a file?

    3. and how to load them back into their associated controls again?

    Please Help.


  2. #2
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: saving/loading contol info

    1. Get the name of the form I am using (I use about 20 different forms in the program)?
    Simple : Me.Name for the Name & Me.Caption for the Caption

    2. Write text containing info from Textboxes and Option button controls to a file?
    3. and how to load them back into their associated controls again?

    For 2. & 3. u should have a routine to convert the contents associated with each control, before putting to text file & before putting to controls

    To read/write files the following code is copied from MSDN
    Dim MyDate as date, NewDate as date
    Dim MyNumber as Variant
    MyDate = #8/2/67#
    MyNumber = 123.45
    Open "Testfile" for Output as #1
    Write #1, MyDate, MyNumber
    Close #1

    Open "Testfile" for input as #1
    input #1, MyDate, MyNumber
    NewDate = Format(Mydate, "Long date")
    Debug.print NewDate, MyNumber
    Close #1


    Srinika






    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  3. #3
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    8

    Re: saving/loading contol info

    Thanks Srinika,

    But just in relation to that, How do I assign the MyNumber variable with the text or value associated with the controls I wish to extract the data from (TextBox and Option Button Controls).

    I may be naive, but please help. Thanks in advance.

    Jason


  4. #4
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: saving/loading contol info

    MyNumber as double
    MyChkBoxValue as string
    ' Say, when the MyChkBoxValue is clicked --> Integer
    ' & when the MyChkBoxValue is NOT clicked --> Non Integer

    MyNumber = Val(txtMyNumber) ' txtMyNumber is the text box containing the number u want to save
    ' chkIsInteger is the check box coorresponding to the status of the number , whether it is a Integer or not
    if chkIsInteger then
    MyChkBoxValue = "Integer"
    else
    MyChkBoxValue = "NonInteger"
    End if
    Open "Testfile" for Output as #1
    Write #1, MyNumber, MyChkBoxValue
    Close #1



    As same as above u do the read from file part, with the help of my earlier answer for u to learn
    Good Luck
    Srinika



    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  5. #5
    Join Date
    Oct 2001
    Location
    Australia
    Posts
    8

    Re: saving/loading contol info

    Thanks Srinika, you have solved a few of my problems with one response.

    Thanks alot.
    Jason


Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)