• 0
Sign in to follow this  
BrunoVeríssimo

Limpar Campos

Question

Eu quero limpar os campos do form, mas pra isso estou usando Modulo pra poder usar o recurso em todas as telas....eu to usando assim....

Public Sub LIMPACAMPOS(ByRef Formulario As Form)

Dim Controles As Object

For Each Controles In Formulario

If TypeOf Controles Is TextBox Then

Controles.Text = ""

Else

If TypeOf Controles Is CheckBox Then

Controles.Value = False

End If

End If

Next

End Sub

...não tem como eu usar um Select case pra diminuir o tamanho do código???

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

não. mas pode tirar uns end ifs, fazendo assim:


For Each Controles In Formulario
If TypeOf Controles Is TextBox Then
Controles.Text = ""
ElseIf TypeOf Controles Is CheckBox Then
Controles.Value = False
End If
Next
End Sub[/code]

Share this post


Link to post
Share on other sites
  • 0

Você pode fazer com o Select Case da seguinte maneira:

        Select Case TypeName(controle)
            Case "TextBox"
                controle.Text = ""
            Case "CheckBox"
                controle.Value = False
        End Select

Certo? ;)

Graymalkin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this