|
-
Jan 15th, 2003, 02:29 PM
#1
Thread Starter
Hyperactive Member
"Simplification" *[RESOLVED]*
I have the following code (quite a lot of it actually):
VB Code:
Case "Misc Quick Tips"
Dim docPath As String = IO.Path.Combine(Application.StartupPath, "code\tips\tips.rtf")
rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)
rtbcodewindow.Focus()
StatusBar1.Text = "Code Section: Misc / Quick Tips"
'Internet
Case "Web graphic into picbox"
Dim docPath As String = IO.Path.Combine(Application.StartupPath, "code\internet\urlpicbox.rtf")
rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)
rtbcodewindow.Focus()
StatusBar1.Text = "Code Section: Internet / How to get a picture from a URL into a picturebox"
'Tutorials
Case "Menus"
Dim docPath As String = IO.Path.Combine(Application.StartupPath, "code\tutorials\menus.rtf")
rtbcodewindow.LoadFile(docPath, RichTextBoxStreamType.RichText)
rtbcodewindow.Focus()
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.
-
Jan 15th, 2003, 06:51 PM
#2
Fanatic Member
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
-
Jan 15th, 2003, 07:01 PM
#3
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|