Results 1 to 8 of 8

Thread: [2005]Code VB6 to VB.Net

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2008
    Posts
    130

    [2005]Code VB6 to VB.Net

    I have this code: VB6

    Code:
    create an file.txt that has the following lines inside
    
    Open "file.txt" For Output As #1
    Write #1, "WindowMode" "0"
    Write #1, "Graphic", "0"
    Write #1, "ColorBPP", "16"
    Write #1, "Network", "0"
    Write #1, "CameraInvert", "false"
    Write #1, "MotionBlur", "false"
    Write #1, "CameraSight", "ON"
    Write #1, "ScreenSize", "0"
    Write #1, "Sound", "On"
    Write #1, "Server1", "64.56.75.249"
    Write #1, "Server2", "64.56.75.249"
    Write #1, "Server3", "64.56.75.249"
    Write #1, "Account", "  "
    Close #1
    how change to VB.Net ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005]Code VB6 to VB.Net

    Your first stop should always be MSDN.

    http://search.msdn.microsoft.com/Def...us&refinement=

    Look first, ask questions later. We can help with specifics but, in my opinion at least, you should always look for yourself first. That's how you learn the most.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005]Code VB6 to VB.Net

    Use the System.IO class.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2008
    Posts
    130

    Re: [2005]Code VB6 to VB.Net

    Here code:

    vb Code:
    1. Dim objStreamWriter As StreamWriter
    2.  
    3.         objStreamWriter = New StreamWriter("Testfile.txt")
    4.         objStreamWriter.WriteLine("line1")
    5.         objStreamWriter.WriteLine("line2")
    6.         objStreamWriter.WriteLine("line3")
    7.  
    8.         objStreamWriter.Close()

    Thanks!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2008
    Posts
    130

    Re: [2005]Code VB6 to VB.Net

    Problem!!

    I need write this line in file: "WindowMode" "1"

    Then I make:

    Code:
    objStreamWriter.WriteLine(""WindowMode" "1"")
    " + " = ERROR

    ERROR: Comma, ')', or a valid expression continuation expected.

    Help

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005]Code VB6 to VB.Net

    Any literal double quotes in a string must be escaped with an extra double quote:
    vb.net Code:
    1. objStreamWriter.WriteLine("""WindowMode"" ""1""")
    Note that that is true of any string literal. It's not specific to writing files.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005]Code VB6 to VB.Net

    Double up on the double quotes.

    Try...
    Code:
    objStreamWriter.WriteLine("""WindowMode"" ""1""")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2008
    Posts
    130

    Re: [2005]Code VB6 to VB.Net

    *.*

    Thanks again man ;P

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