Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VB 6 Newbie
Message
De
03/04/2005 10:14:03
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brésil
 
 
À
02/04/2005 21:57:03
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01001065
Message ID:
01001091
Vues:
14
Hi Ty,

>I have created a form with various TextBoxes and a Submit button. What I need to accomplish is when the user clicks "Submit", it will display a messagebox informing the user which field isn't completed. My setup so far...
>====================================================
>Private Sub Form_Load()
>
>'create variable to store field name
>  Dim strFieldName As String
>
>End Sub
>====================================================
>Private Sub txtFirstName_Change()
>
>'store the textbox name, used for cmdSubmit
>   If Me.txtFirstName.Text = "" Then
>      strFieldName = "First Name"
>   Else
>      strFieldName = ""
>   End If
>End Sub
>====================================================
>Private Sub cmdSubmit_Click()
>
>'if field is empty, alert user which field is empty
>   If Not strFieldName = "" Then
>      MsgBox "Missing Information: " & strFieldName
>   End If
>
>End Sub
>====================================================
>This will display a messagebox everytime the Submit button is clicked, whether the field is empty or not. And it does not display strFieldName. Maybe I looked over something small. I've been trying to figure this out for a while. Any feedback welcome! Thanks!
>-wh0racle

I think that is better check empty textbox with: IF Len(Trim(strFieldName)) = 0.
Maybe be better you to do a "Do While" and to check each TextBox when user clicks Submit button. With the code you typed in Change event has a problem, see the situation:
User enter in txtFirstName and he isn't fill. The variable strFieldName will be "First Name". So, he goes to txtNextText and he fills it. In this case the variable txtFirstName will be "". When user clicks in Submit button no message will be showed, but txtFirstName is empty.
Good luck!
Erick
Força Sempre!
Strength Always!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform