如何判断数组内元素的值等于指定字串 ??
Private Sub Form_Load()For i = 1 To PidCount
hPID = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, PidNum(i))
If hPID <> 0 Then
ModuleName = Space(255)
GetModuleBaseName hPID, 0, ModuleName, 255 '
Combo1.AddItem ModuleName '列出找到的PID与进程名称
End If
CloseHandle hPID
Next
End Sub
----------------------------------------------------------------------------
Private Sub Combo1_LostFocus()
For i = 1 To PidCount
If PidName(i) = Combo1.Text Then
Text1.Text = "i = " & i & Combo1.Text & vbCrLf → 不成功
End If
Next
End Sub
如上面代码,已成功将"PID与进程名称"放入Combo1中,
请问如何判断Combo1.Text(如"VB6.EXE")与PidName(i)的元素值相等?
--------------------编程问答-------------------- 判断条件中 trim(PidName(i)) = trim(Combo1.Text)
不能说是标准答案,不过有些进程名会包含空格(我的例子是AB 的rsLinx进程)因此如果PIDname数组的值是程序员指定的话,最好trim一下去掉空格再比较。希望有参考价值 --------------------编程问答-------------------- Combo1.AddItem ModuleName '列出找到的PID与进程名称
改为:
Combo1.AddItem Left(ModuleName, InStr(1, ModuleName, Chr(32)) - 1)'也可能要将 chr(32)改为 chr(0)
补充:VB , 基础类