求助:应该用什么变量或是什么方法简化代码?我达到目的,但很笨,我知道.
求助:应该用怎么用变量或是用什么方法判断以达到简化代码的目的.这样写虽然通过,但很笨,我知道.
Private Sub TreeView1_Click()
Dim clkname As Variant
Dim y As Integer '计数器
clkname = TreeView1.SelectedItem.Index
If clkname <> 1 And clkname <> 2 And clkname <> 6 And clkname <> 12 And clkname <> 19 And clkname <> 27 And clkname <> 32 And clkname <> 35 And clkname <> 38 And clkname <> 42 And clkname <> 45 And clkname <> 48 And clkname <> 51 And clkname <> 53 Then
Data1.Recordset.Index = "姓名"
Data1.Recordset.Seek "=", TreeView1.Nodes(clkname).Text
End If
End Sub
我的意图是:在treeview树里选中这些之外的结点后再执行查找需要的命令行.
[解决办法]
要排除的结点不是非常多的话:
Select Case (clkname)Case 1, 2, 6, 12,19,27,32,35,38,42,45,48,51,53 '选中这些结点要执行的代码Case Else '选中其它结点要执行的代码End Select