Hello, I'm currently trying to create a create account form with two textboxes (PlayerUsername, PlayerPassword), a label (ErrorMsgLbl) and a button (CreateAccountBtn). My current aim is to get the Error label to update if the requirements for the name and password are not met. Currently I dont have any errors! Except it won't display the message if the input wrong, there's no response. Sorry this is probably a silly error. Pasted below is my code and I was wandering how to call for my functions to work because I made them private but im trying to make ti public and I feel like the errors right infront of me. This is VB 6 by the way. Any help is appreciated.
Code:Imports Microsoft.VisualBasic.ApplicationServices Public Class FrmCreateAccount Dim PlayerNameValid As Boolean = False Dim PlayerPasswordValid As Boolean = False Private Sub CreateAccountBtn_Click(sender As Object, e As EventArgs) Handles CreateAccountBtn.Click While PlayerNameValid = True And PlayerPasswordValid = True ErrorMsgLbl.Text = ("Account creation successful. Please sign in") Me.Hide() FrmLogin.Show() 'this is intended to navigate the user back to the login page where they use these creditentials (im planning to write them to a file later) End While End Sub Private Function ValidatePlayerName(PlayerUsername As String) If PlayerUsername.Length < 3 Then PlayerNameValid = False ErrorMsgLbl.Text = ("Username is too short. Aim to have more than 3 characters.") ElseIf PlayerUsername.Length > 10 Then PlayerNameValid = False ErrorMsgLbl.Text = ("Username is too long. Aim to have less than 10 characters.") Else PlayerNameValid = True End If Return PlayerNameValid End Function Private Function ValidatePlayerPassword(PlayerPassword As String) Dim PlayerPasswordValid As Boolean = False If PlayerPassword.Length < 6 Then PlayerPasswordValid = False ErrorMsgLbl.Text = ("Password is too short. Aim to have more than 6 characters.") ElseIf PlayerPassword.Length > 10 Then PlayerPasswordValid = False ErrorMsgLbl.Text = ("Password is too long. Aim to have less than 10 characters.") PlayerPasswordValid = True End If Return PlayerPasswordValid End Function End Class




Reply With Quote
