compare text from clipboard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • countryboy
    New Member
    • Jul 2007
    • 13

    compare text from clipboard

    I managed to get my text to the clipboard now I am trying to figure out how to compare it two different options. i know the goto is not good but I'm not sure a different way to do it.

    If clipboard text = "this" then goto line 4
    If clipboard text = "that then goto line 5
    If clipboard text = "anything else" give error message box

    Thanks for any input!

    Happy New Years!!!
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Hi

    Can you explain to us in much more details (like goto line 4, ...) and what version of vb are you using.

    Rey Sean

    Comment

    • countryboy
      New Member
      • Jul 2007
      • 13

      #3
      vb 6 The line 4 and 5 are just examples i thought it a had a general idea i could fill in the blanks.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I'd suggest something along these lines...

        [CODE=vb]
        Dim strText As String
        strText = Clipboard.GetTe xt
        Select Case strText
        Case "this"
        ' Do something
        Case "that"
        ' Do something else
        Case Else
        MsgBox "Dunno what that means."
        End Select
        [/CODE]

        Comment

        • countryboy
          New Member
          • Jul 2007
          • 13

          #5
          Originally posted by Killer42
          I'd suggest something along these lines...

          [CODE=vb]
          Dim strText As String
          strText = Clipboard.GetTe xt
          Select Case strText
          Case "this"
          ' Do something
          Case "that"
          ' Do something else
          Case Else
          MsgBox "Dunno what that means."
          End Select
          [/CODE]
          from what I understand the goto command is not good to use. Is the resume command proper to use?

          [CODE=vb]
          Dim strText As String
          strText = Clipboard.GetTe xt
          Select Case strText
          Case "this"
          ' Resume next
          Case "that"
          ' Resume Line 23
          Case Else
          MsgBox "Dunno what that means."
          End Select
          [/CODE]
          Last edited by Killer42; Jan 2 '08, 07:37 AM.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Resume is used to return from an error-handling routine. I doubt it's what you need here.

            It's not that the Goto statement is bad as such, just that in any language that supports a decent code structure it should never be needed. It's generally seen as a symptom of lazy and poorly-structured code. Still works, though. :)
            Last edited by Killer42; Jan 2 '08, 07:38 AM.

            Comment

            Working...