Jump to content

combobox


estica
 Share

Recommended Posts

Boas pessoal,

Estou a usar o seguinte tópico para me apresentar uma lista de pastas em combobox. A minha duvida é como não apresentar as pastas que têm uma palavra espesifica.

Por exemplo como ocultar as pastas com a palavra "TEST"

Try

Dim di As New IO.DirectoryInfo("Data Mod\Select\PASTAS")

Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()

Dim dra As IO.DirectoryInfo

For Each dra In diar1

ComboBox3.Items.Add(dra)

Next

Catch

End Try

Link to comment
Share on other sites

Boa Tarde,

Já sabes como listar as pastas, agora crie a função que verifique se existe a palavra que disseste. Podes fazer dessa forma :

'
Public Shared Function Destroy_First_Byte(ByVal String_Path As String, ByVal String_Additional As String) As String
 Try
	 Dim First_Byte As Boolean = True
	 Dim New_String As String = Nothing
	 For Current_Byte As Integer = 0 To String_Path.Length - 1
		 If First_Byte = True Then
			 First_Byte = False
		 Else
			 New_String = New_String & String_Path(Current_Byte)
		 End If
	 Next
	 New_String = (New_String & String_Additional)
	 If New_String.Length < 1 Then
		 Return Nothing
	 Else
		 Return New_String
	 End If
 Catch NTSTATUS As Exception
	 Return Nothing
 End Try
End Function
'
Public Shared Function Verify_String(ByVal String_Path As String, ByVal String_Hide As String) As Boolean
 Try
	 Dim Current_Bytes As String = Nothing
	 For Current_Byte As Integer = 0 To String_Path.Length - 1
		 Current_Bytes = Current_Bytes & String_Path.Chars(Current_Byte)
		 If Current_Bytes.Length = String_Hide.Length Then
			 If Current_Bytes = String_Hide Then
				 Return True
			 Else
				 Current_Bytes = Destroy_First_Byte(Current_Bytes, Nothing)
			 End If
		 End If
	 Next
	 Return False
 Catch NTSTATUS As Exception
	 Return False
 End Try
End Function
'
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 Dim x As String = "Portugal_a_Programar"
 MsgBox(Verify_String(x, "Muryllo"))
End Sub

Com estas duas funções podes verificar se uma string possui os mesmos bytes sequenciais de outra string. Traduzindo, os mesmos sequenciais de outra string.

Ao colocar esse código no programa vais receber uma MsgBox com o retorno "False" pois a string Muryllo não foi encontrada no Path. Logo, se puseste Portugal ou Programar eu receberia True. Podes adaptar isso ao teu código. Qualquer dúvida ... Diga.

Abraços.

Edited by Muryllo
  • Vote 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.