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

解决了

4

1 回答 1

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
...
于 2013-06-18T17:49:51.260 回答