SABER SE O NOME ESTA NO COMBO

BYDUMORAES 02/05/2005 15:51:37
#81311
Pessoal como saber por exemplo se a maquina MAQ001 esta na relacionada no combo, pois preciso fazer o seguinte se a maquina X estiver logada na rede me mostra uma imagem se nao tiver mostra outra.
LCSD 02/05/2005 16:54:15
#81324
SE VC quiser saber se um determinado texto está num combo, o código seria mais ou menos assim:


for i=0 to combo.listcount-1
if trim(texto) = trim(combo.list(i)) then
msgbox"Achou"
endif
next i
IVOFABIANO 02/05/2005 21:06:21
#81369
Resposta escolhida
Use essa Função

Public Function Verificar (Byval Nome as string) as boolean
dim i%
Verificar = false
for i = 0 to combo.listcount-1
if Nome = combo.list(i) then
Verificar = True
exit for
endif
next

end if

Abraços
IVOFABIANO 02/05/2005 21:07:59
#81370
Use essa Função

Public Function Verificar (Byval Nome as string) as boolean
dim i%
Verificar = false
for i = 0 to combo.listcount-1
if Nome = combo.list(i) then
Verificar = True
exit for
endif
next

end if

Abraços
USUARIO.EXCLUIDOS 03/05/2005 07:44:40
#81383
Usando API:

Private Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

Const WM_USER = &H400
Const CB_FINDSTRING = (WM_USER + 12)


A sintaxe é (com Combo1):

Dim FindString As String

FindString = "Blah"
CB = SendMessage(Combo1.hWnd, CB_FINDSTRING, -1, ByVal FindString)


Se o item estiver relacionado, vai retornar o indice do mesmo, caso contrário, retorna -1.
Tópico encerrado , respostas não são mais permitidas