Results 1 to 3 of 3

Thread: "Simplification" *[RESOLVED]*

  1. #1

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435

    Thumbs up "Simplification" *[RESOLVED]*

    I have the following code (quite a lot of it actually):

    VB Code:
    1. Case "Misc Quick Tips"
    2.                 Dim docPath As String = IO.Path.Combine(Application.StartupPath, "code\tips\tips.rtf")
    3.                 rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)
    4.                 rtbcodewindow.Focus()
    5.                 StatusBar1.Text = "Code Section: Misc / Quick Tips"
    6.  
    7.                 'Internet
    8.             Case "Web graphic into picbox"
    9.                 Dim docPath As String = IO.Path.Combine(Application.StartupPath, "code\internet\urlpicbox.rtf")
    10.                 rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)
    11.                 rtbcodewindow.Focus()
    12.                 StatusBar1.Text = "Code Section: Internet / How to get a picture from a URL into a picturebox"
    13.  
    14.                 'Tutorials
    15.             Case "Menus"
    16.                 Dim docPath As String = IO.Path.Combine(Application.StartupPath, "code\tutorials\menus.rtf")
    17.                 rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)
    18.                 rtbcodewindow.Focus()
    19.                 StatusBar1.Text = "Code Section: Tutorials / Menus"
    and as you can see 90% of it is repeated in each Case statement. I wish to simplyfy this be calling a routine outside of the case statement by passing two arguments, something like this:

    LoadCode(<path to text to load>,<what to display in status bar>)

    I know you need a function and pass arguments, but how? Anybody help with this one?

    Thanks yall
    Last edited by RealNickyDude; Jan 15th, 2003 at 07:36 PM.
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    Code:
    Case "Misc Quick Tips"
                    doStuff("code\tips\tips.rtf","Code Section: Misc / Quick Tips")
     Case "Web graphic into picbox"
                    doStuff("code\internet\urlpicbox.rtf","Code Section: Internet / How to get a picture from a URL into a picturebox")
    
     Case "Menus"
                    doStuff("code\tutorials\menus.rtf","Code Section: Tutorials / Menus")
    
    'in a seperate subroutine
    public sub doStuff(string1 as string, string2 as string)
    
    Dim docPath As String = IO.Path.Combine(Application.StartupPath, string1)
    rtbcodewindow.LoadFile(docPath,RichTextBoxStreamType.RichText)
    rtbcodewindow.Focus()
    StatusBar1.Text = string2
    
    end sub

    hope this is what u r looking for!

    Nick

  3. #3

    Thread Starter
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    Absolutlely spot on

    Excellent, thanks!!

    Beta Release 5 of the VBCodebook .NET is now available!
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

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