Results 1 to 3 of 3

Thread: [RESOLVED]VB .Net 2005 - How to avoid duplicate Select Case (Noob alert)

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    13

    Resolved [RESOLVED]VB .Net 2005 - How to avoid duplicate Select Case (Noob alert)

    I'm writing a program that requires a huge Select Case loop. It analyzes each character of a string and, depending on what character it is, modifies a variable. Here's the first loop:
    VB Code:
    1. Private Sub cmdDo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDo.Click
    2.         txtOutput.Text = "Please wait..."
    3.         strOutput = ""
    4.         strInput = txtInput.Text
    5.         intInLength = txtInput.Text.Length
    6.         i = 1
    7.         For i = 1 To Len(strInput) Step 8
    8.             strCurChar = Mid(strInput, i, 8)
    9.             Select Case strCurChar
    10.                 Case Is = "a"
    11.                     strCurChar = "bogus text"
    12.  
    13. 'all other cases here
    14.  
    15.                 Case Else
    16.                     strCurChar = ""
    17.             End Select
    18.             strOutput = strOutput & strCurChar
    19.             txtOutput.Text = strOutput
    20.         Next
    21.     End Sub

    I've got a second button that will do the same thing as the first loop, but instead of using the data from txtInput, it takes it from the clipboard. All that really needs to change is to assign strInput to the clipboard data instead of the textbox. In my mind, the best way to do this looks like this:

    VB Code:
    1. Private Sub cmdDoFromCB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDoFromCB.Click
    2.         txtInput.Text = Clipboard.GetText()
    3.         RaiseEvent Click(cmdDo)
    4.     End Sub

    But VB gives me an error saying "Derived classes cannot raise base class events."

    Hopefully someone with more experience can show me how to do this without copying the entire loop again into the second button's event. Any help is much appreciated.

    Thanks!
    Last edited by S3CUR3; Jun 6th, 2006 at 05:20 PM.

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