Results 1 to 14 of 14

Thread: Input String Question?

  1. #1

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134

    Question Input String Question?

    I'm having a couple of what I hope to be easy questions?
    I would like the user of my program to give some input via an Input Box, I have 2 labels that need to be filled with Numbers, but I only want it to run once after the initial install. After that if there is any changes I want the user to do it with a menu command.
    Question 1: Will I have to use the registry to do this or is there an easier way?
    Question 2: Looking at the stupid books that I have I still can’t see anything that talks about, “changing label text and such” Would someone be so nice and tell me how?
    PS: I’m not talking changing it in memory, It needs to be permanent. “Hope that made sense”
    Thanks in advance!!!!!!!!

  2. #2
    Junior Member
    Join Date
    Dec 2003
    Location
    California
    Posts
    19
    I've used this technique in a couple of applications. You could create a .dat or .ini file, some random access file, that's not named anything conspicuous(sp?) with the default values to be loaded into this one time form, and a counter value. If its the first time the app is loaded on the persons PC the form you describe loads...the user enters the data which is stored either in that same file or in another file. The next time the app loads if the value of the counter is > 0 then the values of the lables are changed to your permanent text. That way you don't have to play around with the Registry. Hope this all made sense.

    Code:
    'Forms Load event
    Dim fs as System.IO.Filestream = New System.IO.Filestream("your file", FileMode.Open)
    Dim sr as System.IO StreamReader = New System.IO.StreamReader(fs)
    Dim appCount as Integer
    
         appCount = sr.ReadLine
    
    
    if appCount > 0 then
      Me.MyLabel.Text = "Your Text"
    Else
      Me.MyLabel.Text = "Something Else"
      appCount = appCount + 1
      'Write value back to your file 
    End If
    'Close your FileStream and StreamReader Objects

  3. #3

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Let me just tell you what I’m doing that way it will be easier to communicate.
    I thought about making a small app. that will be used like a check register, It is supposed to keep track of the persons checking account “Yes I know! Money works well”.
    I would like for the Program too start up and prompt the user for a Routing Number and then the Account Number. I wanted to do this via an InputBox.
    This info. Is not required but I thought it may be handy to have at times.
    Is this feasible?? Or is it more trouble than what it’s worth?
    Also! Like always I did not look at the big picture and found that this is not the only problem I have. In my file menu I added a command to also change these values (Numbers) at a later time but trying it I came to find out that the changes made while using it where not permanent the next time I started the app. the labels where back to original.
    Any help would be greatly appreciated!

    Are there any books that teach this stuff in more detail?

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Design:

    1) You need to grab INITIAL values for checking number, check number, etc. This is really logic seperate from your main program.


    2) You then need to store these values on drive somewhere.


    3) Everytime your program starts thereafter, it needs to read in these values.

    So if the file where you put these values doesn't exist, your program will ask for the values.

  5. #5

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Yes I do understand that, the example that betrl8thanever has made sounded real good, unfortunately I have not ventured into the world of using logics yet.
    Is there something that I can read that would explain this in detail.
    Thanks!
    Last edited by Rally2000; Dec 14th, 2003 at 03:19 PM.

  6. #6
    Junior Member
    Join Date
    Dec 2003
    Location
    California
    Posts
    19
    Logic is nothing more than linear thinking... If this....do this...Else...do somthing else...With as many tiers of logic as needed.....In this case you know what you want the user to do...If they haven't launched the application then set the properties of these controls to something....If they have launched it before then set them something else.....I don't know any good articles off the top of my head...but I will research some and reply back.

  7. #7

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Thanks for that info. it is always nice to have people lend a hand.
    However easy all of this may be, but fact remains that it has to be learned somehow. And lots of times I can't even produce a result serching on the net.
    Thanks for taking the time to help!

  8. #8
    Junior Member
    Join Date
    Dec 2003
    Location
    California
    Posts
    19
    Do a search in the VB.NET Help on "IF Expressions". Couple that with System.IO.Filestream and System.IO.StreamReader/Writer. This should get you pointed in the right direction. If you need sample code or coding help, let me know.

  9. #9

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Still dont get it!

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What don't you 'get'? The more specific you are the more likely you will understand the answer.

  11. #11

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    Looking at and reading about the System IO!
    I still can't get my app to work.
    My input box is calling for an account # that is supposed to be placed in a Label on my frmMain.
    From what I have read this can only be achieved by using File IO strings by saving some text.
    unfortunately I'm unable to get this done, If someone could give me an example for my case I sure would appreciate it.
    Thanks!!

  12. #12
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you dont appear to need System.IO for this. you can write your values to the registry on first run , then retrieve them each time after, eg:
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", True)
    3.         If regKey.OpenSubKey(Application.ProductName, True) Is Nothing Then
    4.             regKey.CreateSubKey(Application.ProductName).SetValue("label1", "20")
    5.             regKey.OpenSubKey(Application.ProductName, True).SetValue("label2", "50")
    6.             Me.Text = "this is your first time using the Application!"
    7.             Label1.Text = 20
    8.             Label2.Text = 50
    9.         Else
    10.             Me.Text = "you are a registered user!"
    11.             Label1.Text = regKey.OpenSubKey(Application.ProductName, False).GetValue("label1")
    12.             Label2.Text = regKey.OpenSubKey(Application.ProductName, False).GetValue("label2")
    13.         End If
    14.  
    15.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  13. #13

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134
    HI dynamic_sysop
    hope this does not offend you but that still don't tell me much.
    I'm having a problem finding the Info. on the subject period.
    although I can somewhat see what that code is doing I still don't see how to get there.
    I have never used any advanced functions. all I did so far is the examples in my books, and to be honest I don't think they are off much use in the real world.

  14. #14
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    ok well here's a break down ...
    VB Code:
    1. Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", True)
    2. '/// this gets the registrykey " HKEY_CURRENT_USER\Software\ "
    3. '///
    4. If regKey.OpenSubKey(Application.ProductName, True) Is Nothing Then '///....
    5. '/// the code within the If statement checks if the registry key for your application exists or not , starting with the above line ^^^
    6. '///
    7.             regKey.CreateSubKey(Application.ProductName).SetValue("label1", "20")
    8.             regKey.OpenSubKey(Application.ProductName, True).SetValue("label2", "50")
    9. '/// if the key doesnt exist , create it / set it's values ^^^
    10. '///
    11. '/// if the key does exist ......
    12.             Label1.Text = regKey.OpenSubKey(Application.ProductName, False).GetValue("label1")
    13.             Label2.Text = regKey.OpenSubKey(Application.ProductName, False).GetValue("label2")
    14. '/// get the values because it exists ^^^
    i have never read a vb.net book in my life , i have taught myself all i know and am proud of it , you aint offended me , it'll all start making sense as you stick with it.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

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