+ Post New Thread
Results 1 to 15 of 15
Coding Thread, vb help in Coding and Web Development; I am new to Visual Basic and am looking for a little help. I have 2 .vbs files (which I ...
  1. #1
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15

    vb help

    I am new to Visual Basic and am looking for a little help.

    I have 2 .vbs files (which I got off edugeek) that I can double click one to turn on proxy settings and one to turn them off, I have managed to get my hands on visual basic studio 2005 and wanted to make a simple app but I am finding it difficult,

    here is the script

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\In ternet Settings\ProxyEnable","1","REG_DWORD"
    WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\In ternet Settings\ProxyServer","PROXY:PORT","REG_SZ"
    Wscript.Echo " Proxy Settings Added "



    I have designed the app and wanted to add funtionality to one of the buttons... thought I could double click the button and paste the code in? Obv not...

    Is it because wshshell cannot run inside visual basic studio?

    Any help welcomed...

  2. #2

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,941
    Thank Post
    519
    Thanked 2,499 Times in 1,940 Posts
    Blog Entries
    24
    Rep Power
    840
    VBS is different to Visual Basic .net - one is a scripting language, the other is a programming language.

    To make an application which would switch reg settings on the press of a button, you'd need to make use of the Microsoft.Win32 library, and the 'Registry' and 'RegistryKey' objects.

    I'd suggest grabbing a VB.Net book and picking up the basics of the language before trying that though.

    Personally, I'd also say to use C# instead of VB.net - the syntax makes more sense I find.

  3. #3
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15


    Thank you, thought that they were the same but visual basic let you create a a GUI... Back to the books...

  4. #4
    jmcdermott's Avatar
    Join Date
    Feb 2008
    Location
    Cornwall
    Posts
    174
    Thank Post
    16
    Thanked 43 Times in 35 Posts
    Rep Power
    21
    Not sure if it helps but here is the VB6 code to perform this task.


    dim key as string
    dim create
    dim regsetting

    key = "HKEY_CURRENT_USER\software\microsoft\windows\curr entversion\internet settings\proxyenable"
    Set create = CreateObject("wscript.shell")
    regsetting = 1
    create.regwrite key, regsetting, "REG_DWORD"
    'create.regwrite ("hkcu\software\microsoft\windows\currentversion\i nternet settings\proxyenable", "1", "reg_dword")
    msgbox = "Proxy Now: Enabled"

  5. #5
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    I am working with visual basic 2005 express edition I got it for free and I am have very little knowledge, I have copied it in and seems to work ok, do you have one for disable proxy?

  6. #6
    jmcdermott's Avatar
    Join Date
    Feb 2008
    Location
    Cornwall
    Posts
    174
    Thank Post
    16
    Thanked 43 Times in 35 Posts
    Rep Power
    21
    yes just change the regsetting var to 1 instead of 0.

  7. #7

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,941
    Thank Post
    519
    Thanked 2,499 Times in 1,940 Posts
    Blog Entries
    24
    Rep Power
    840
    Another issue there, you are using Visual Studio 2005 Express - Visual Basic edition. This is a cut down version of Visual Studio, which only allows the use of Visual Basic.net. The code that jmcdermott posted is VB6 - an older, and now defunct, language.

    Information on VB.net registry interaction is available here: Accessing the Registry with Visual Basic .NET

  8. #8
    jmcdermott's Avatar
    Join Date
    Feb 2008
    Location
    Cornwall
    Posts
    174
    Thank Post
    16
    Thanked 43 Times in 35 Posts
    Rep Power
    21
    Maybe older and defunct, but it is what was around when I started IT and still serves a use.

    I find coding in .NET takes a lot longer to perform the simple tasks.

  9. #9
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    The code went in with no errors however doesnt work, maybe I should stop being a cheap skate and buy the latest version rather than messing about with this?

  10. #10
    jmcdermott's Avatar
    Join Date
    Feb 2008
    Location
    Cornwall
    Posts
    174
    Thank Post
    16
    Thanked 43 Times in 35 Posts
    Rep Power
    21
    Which Browser are you using?

    Also it may require the browser to exit and open again before it takes effect.

  11. #11
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    What browser am I using? should it make a difference? IE8... but I can run the application and nothing happens...

    ublic Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim key As String
    Dim create
    Dim regsetting

    key = "HKEY_CURRENT_USER\software\microsoft\windows\curr entversion\internet settings\proxyenable"
    create = CreateObject("wscript.shell")
    regsetting = 1
    create.regwrite(key, regsetting, "REG_DWORD")
    'create.regwrite ("hkcu\software\microsoft\windows\currentversion\i nternet settings\proxyenable", "1", "reg_dword")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim key As String
    Dim create
    Dim regsetting

    key = "HKEY_CURRENT_USER\software\microsoft\windows\curr entversion\internet settings\proxyenable"
    create = CreateObject("wscript.shell")
    regsetting = 0
    create.regwrite(key, regsetting, "REG_DWORD")
    'create.regwrite ("hkcu\software\microsoft\windows\currentversion\i nternet settings\proxyenable", "0", "reg_dword")

    End Sub
    End Class

    This is code I have in place I only want 2 buttons one to turn on one to turn off...
    Last edited by neon; 14th December 2009 at 09:56 AM.

  12. #12
    jmcdermott's Avatar
    Join Date
    Feb 2008
    Location
    Cornwall
    Posts
    174
    Thank Post
    16
    Thanked 43 Times in 35 Posts
    Rep Power
    21
    Firefox and chrome do not user the reg setting.
    have you checked the reg key using regedit after running the program?

  13. #13
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0
    why use VB?

    there's an autoit script on this forum somewhere, very easy to change to

  14. #14

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,941
    Thank Post
    519
    Thanked 2,499 Times in 1,940 Posts
    Blog Entries
    24
    Rep Power
    840
    I think you're getting a bit mixed up here.

    VB6 code simply will not work in Visual Studio.net without special addons etc... It isn't supported any more, so unless you have the VB6 program installed, it will be no use.

    The code you need will be possible if you use the link I provided.

  15. #15
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    222
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    15
    Thank you, I am in the process of reading through and trying out your link...

SHARE:
+ Post New Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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