2013-06-18 38 views
0

我需要在分析器字符串中做一個選擇案例。我需要選擇第二個字段(工作正常),然後基於第二個字段返回字符串的明智之處,我需要將它切換一點點,但由於某種原因,它不太合適,我想我可能不會綁定它對r的權利,不確定。在分析字段中選擇案例

   Dim r as DataRow 
       Dim command = fields(1) 
       Select Case command 
        Case 1 
         If fields(1) = "<Left Mouse Down> <Left Mouse Up> <Right Mouse Up>" Then 
          r("Mouse Command") = "Left Click" 
         End If 

        Case 2 
         If fields(1) = "<Right Mouse Down> <Left Mouse Up> <Right Mouse Up" Then 
          r("Mouse Command") = "Right click" 
         End If 

        Case 3 
         If fields(1) = "<Left Mouse Up> <Right Mouse Up>" & Microsoft.VisualBasic.LTrim("Scroll Wheel Roll") Then 
          r("Mouse Command") = "Scroll Wheel" 
         End If 

        Case 4 
         If fields(1) = Microsoft.VisualBasic.LTrim("<Left Mouse Up> <Right Mouse Up> <Press ") Then 
          r("Mouse Command") = "Key Press" 
         End If 

        Case 5 
         If fields(1) = "<Left Mouse Up> <Right Mouse Up>" Then 
          r("Mouse Command") = "Double Click" 
         End If 

       End Select 

解決

+1

把休息在選擇案例,並期待在各種變量。 – dbasnett

回答

0

我想你所訪問的field錯誤的索引地方。在行Dim command = fields(1)If fields(1) = ...陳述中。

fields(1)不能同時1和5之間也許多包含Left Mouse Down ...

字符串你的第一個案例,例如:

Dim command = fields(1) '' You're accessing fields(1) here looking for an int 
Select Case command 
    Case 1 
     If fields(1) = "..." '' and here, but looking for a string 
...