Results 1 to 13 of 13

Thread: Test App needs help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Smile Test App needs help

    • I build a small test app. no code behind it, as I tend to be visual person. When I see it work I can understand it. Thanks. For understanding.
    • I don't know if you guys can help because I asked a few of my friends and they can't see it either?
    • My test app has 6 controls - 1 is a txt box, 4 buttons, 1 label.
    • My problem is when the app opens, I want it to get the computer Ip address and place that in the text box.
    • Press one of the buttons and create a registry, or use one not being used by anyone. So this does not damage OS when testing app…..
    • Press another button and check the now empty registry with the txt box. If no match label says no match.
    • Press another button and place the contents of the text box into that registry. Test again with button. If match label says OK matches.
    • Press another button and empty the registry.
    • Is this hard to do because we can't find how to do it? Your help would be appreciated... See app. If anyone can solve, I would be happy to see it work and try it myself. I will learn a lot from this test app and your help . Thanks again
    Attached Files Attached Files

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Test App needs help

    Winsock will get you the LocalIP

    But, "create a test reigstry"

    Perhaps simulating a registry with a treeview control might be worth investigating.

    Or, creating a series of folders of the root drive that performs the function of an OS registry might be a way to go.

    But, you aren't going to be able to create a "real" registry unless you create a dummy key in the real registry, and create you sub entries off of it. I wouldn't suggest that approach as it would put you in the "real" registry.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Smile Re: Test App needs help

    Thanks. You may be very right. I don't know how to do this. I've tried a few people and friends, etc

    I think the guy who gets this app to work will diserve 5 stars. No one I know can solve this. Thank you everyone for trying

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Test App needs help

    You could very well create your own "registry". A flat file database, or however you want to do it. It depends on how close you want it to resemble the real Windows registry, if you want to have it support importing of .reg, etc.

    You could use a UDT array for the basic structure of holding registry entries, and set it up in a heiarchial view. Or a real database might be the way to go. That would also depend on how many values will be stored in it.

    As for the IP address, look at the link in my signature, "Get external IP from any IP site".

  5. #5
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Test App needs help

    You don't have to have a 'temporary' Registry. If you use the GetSetting Function and the SaveSetting and DeleteSetting Statements you can manage your own keys in a "safe" part of the existing Registry with no fear of messing anything else up.

    eg
    Code:
    SaveSetting "myapplication", "TestKey", "KeyName", "This is the value"
    Will create a registry entry vis:
    HKEY_CURRENT_USER\Software\VB and VBA Program Settings\myapplication\TestKey
    which will hold a Key of KeyName with the value "This is the value"

    To read the value back use the GetSetting statement:
    Code:
    Dim strDefault As String
    Dim strKeyValue As String
    strKeyValue = GetSetting("myapplication", "TestKey", "KeyName", strDefault)
    If strKeyValue <> "" Then
        MsgBox strKeyValue
    Else
        MagBox "Key Not Found"
    End If
    End Sub
    strDefault is the default value you can set in strKeyValue if the key is not found in the Registry. It defaults to a Null string. So if any part of the key was not found strKeyValue will be set to the value of strDefault.

    Finally to delete the entry you can use the DeleteSetting statement:
    Code:
    DeleteSetting "myapplication", "TestKey", "KeyName"
    Using those Functions / Statements you should be able to achieve what you want to do.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Smile Re: Test App needs help

    You don't have to have a 'temporary' Registry. If you use the GetSetting Function and the SaveSetting and DeleteSetting Statements you can manage your own keys in a "safe" part of the existing Registry with no fear of messing anything else up.

    This sounds like an excellent suggestion. Can you do me a favor and place this code in the app I prensented above. This will really help me. I need to get the computer IP and place in this file. Thank you very much. I will then see the app working and understand what you have done. Thank you so very much

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Test App needs help

    Something like this:
    Code:
    Private Sub Command1_Click()
    SaveSetting App.EXEName, "Check", "IP", vbNullString
    End Sub
    
    Private Sub Command2_Click()
    Dim strIPValue As String
    Dim strDefault As String
    strIPValue = GetSetting(App.EXEName, "Check", "IP", strDefault)
    If strIPValue <> Text1.Text Then
        Label1.Caption = "No Match"
    Else
        Label1.Caption = "Match"
    End If
    End Sub
    
    Private Sub Command3_Click()
    SaveSetting App.EXEName, "Check", "IP", Text1.Text
    End Sub
    
    Private Sub Command4_Click()
    DeleteSetting App.EXEName, "Check", "IP"
    End Sub
    
    Private Sub Form_Load()
    Text1.Text = Winsock1.LocalIP
    End Sub
    You'll need to add a Winsock control to your project (Project -> Components -> Microsoft Winsock Control SP6)

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Smile Re: Test App needs help

    You are a master at this, I thank you. I'm having a problem understanding this, as i am new at this, sorry. I would be most grateful if you could kindly place this into the app I provided. Thankyou. I am extremely grateful for this and with the working app, I can digest what you kindly did. Thank you again for understanding.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Test App needs help

    He has given you the code which you can copy and paste directly off this web page. What more do you need?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Re: Test App needs help

    Private Sub Command4_Click()
    DeleteSetting App.EXEName, "Check", "IP"
    End Sub
    I placed the above code in the app. When I try to clear the regisrty with the above I get - Error #5 - Invalid procedure?? Is this because the registry is already empty? The IP work OK, as this is a nice little exercise to see how to use this registry. So using this method is OK overall to enter into a test registry? Also will this work OK on Vista? I only ask because I'm assuming Vista won't allow someone to make there own registry, or is this incorrect?

    Once a value is put in this registry, whatever it is, I assume it will remain there util it is *deliberately* deleted? Can briefly describe to me what this code is doing, so I can understand it? Thanks


    If I go into my system how do I trace down the location of this Key. Thank you for your *great* help........

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Smile Re: Test App needs help

    He has given you the code which you can copy and paste directly off this web page. What more do you need?
    Thank you. I realize this. I just wanted the app to work OK, that's all so I could learn from something without errors. That was all. Sorry. I'm getting this Error #5 now......

    My intentions are to learn and I appreciate the help Thank you.

  12. #12
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Test App needs help

    Yes, the DeleteSetting will fail if any part of the Registry key is missing. You can use in-line Error Checking to ignore that type of failure. eg
    Code:
    Private Sub Command4_Click()
    On Error Resume Next
    DeleteSetting App.EXEName, "Check", "IP"
    On Error GoTo 0
    If Err.Number <> 0 And Err.Number <> 5 Then
        MsgBox "Error Deleting Registry Key " & Err.Description
    End If
    End Sub
    If you re-read my first post you'll see where the key resides in the Registry.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    97

    Re: Test App needs help

    Private Sub Form_Load()
    Text1.Text = Winsock1.LocalIP
    End Sub
    Help Please......I tried my small app today. When it loaded up it DID NOT SHOW MY SYSTEM IP??? I had checked my system IP yesterday to make sure I knew what it was. I tried my system IP again today, after running this app and it gives me some number which is not reading my system. Also: My system IP is saying *media disconnected*??? How do I reset my system IP?? Why did it do this.........Please help................ Is my system OK, no system IP???

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