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:
Private Sub cmdDo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDo.Click txtOutput.Text = "Please wait..." strOutput = "" strInput = txtInput.Text intInLength = txtInput.Text.Length i = 1 For i = 1 To Len(strInput) Step 8 strCurChar = Mid(strInput, i, 8) Select Case strCurChar Case Is = "a" strCurChar = "bogus text" 'all other cases here Case Else strCurChar = "" End Select strOutput = strOutput & strCurChar txtOutput.Text = strOutput Next 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:
Private Sub cmdDoFromCB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDoFromCB.Click txtInput.Text = Clipboard.GetText() RaiseEvent Click(cmdDo) 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!




Reply With Quote