Click here to Skip to main content
15,898,923 members

Comments by faiqaa (Top 32 by date)

faiqaa 21-Mar-18 17:31pm View    
oh yes I did, I thought you were talking about the last comment, sorry for misunderstanding.
faiqaa 21-Mar-18 17:27pm View    
But sir, you've written "If PresenceCheck" I have not used that in my code and I would need to declare it.
faiqaa 21-Mar-18 17:19pm View    
Wait, have you responded to the main question at the top? or to the comments?
faiqaa 21-Mar-18 16:26pm View    
Sir I'm trying my best in understanding what you said, since I had to also add a validation for the phone numbers I've done that,I'm still facing the same issue both validation fail the data should be saved which is currently happening, even if one text box is empty the data should not be saved and if the phone number is any lower than 9 or bigger than 11 then the same should happen.

The code that I have now is:

Dim pattern As String = "^txtBox\d$"
Dim r As Regex = New Regex(pattern)
Dim msg As String = String.Join("; ", Me.Controls.OfType(Of TextBox) _
.Where(Function(x) x.Text.Trim.Length = 0 And r.Match(x.Name).Success) _
.Select(Function(x) x.Name) _
.ToList())
If msg <> "" Then MsgBox("Please, fill the following textboxes: " & vbCr & _
msg, MsgBoxStyle.Information, "Information")

msg = String.Join(",", Me.Controls.OfType(Of TextBox) _
.Where(Function(x) x.Text.Trim.Length > 0 And r.Match(x.Name).Success) _
.Select(Function(x) String.Concat(x.Name, ":", x.Text)) _
.ToList())


If txtBox5.Text.Length < 9 Then
MsgBox("Phone numbers must be at least 9 digits long") ' if the value entered in text box 5 is < 9 then the respective message box would be shown'
txtBox5.Focus()
MessageBox.Show("Customer has not been successfully registered")
End If
If txtBox5.Text.Length > 11 Then
MsgBox("Phone numbers must be of a maximum of 11 digits long") ' if the value entered in text box 5 is > 11 then the respective message box would be shown'
txtBox5.Focus()
MessageBox.Show("Customer has not been successfully registered")
End If

If msg <> "" Then
Dim Filenum As Integer = FreeFile()
FileOpen(Filenum, "C:\Users\Windows 7 User\Desktop\Customers.txt", OpenMode.Append) 'Text file is opened'
PrintLine(Filenum, txtBox1.Text & "," & txtBox2.Text & "," & txtBox3.Text & "," & txtBox4.Text & "," & txtBox5.Text & "," & txtBox6.Text) 'The data entered in the above text boxes is combined together separated with commas and stored into the open text file'
FileClose(Filenum) 'Once this is done the text file is closed and message below is displayed'
MessageBox.Show("Customer has been successfully registered")
End If

Sir I do understand you want me to learn but right now I'm really desperate since I have a deadline for tomorrow,I've started to code from a few months. I really don't know what to do next.
faiqaa 21-Mar-18 15:25pm View    
That's fine, if I look at both where statements they do seem to be fine, in the first the length must be equal to 0 and in the second one it needs to be bigger than 0 since I'm dealing with the filled in text boxes.