Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

string

Hi
who we can check the password to make sure ti has only alphabetic characters nothing else.
Thank you

Comments

  • cpravincpravin Member Posts: 21
    : Hi
    : who we can check the password to make sure ti has only alphabetic characters nothing else.
    : Thank you
    :
    :

    Well you can write a validation function or inline code in the function to check whether each the characters in textbox are all aplhabetic. If any charatcer is not alphabetic then you can discard it.

    this can be done as follows


    VB.NET
    Public Sub CheckPassword(byval pass as string)
    dim i as integer
    dim flag as boolean = true

    for i=0 to i='A' and pass(i)<='Z' ) or _
    ( pass(i)>= 'a' and pass(i)<='z') ) then
    flag = false

    if flag then
    msgbox("Valid")
    else
    msgbox("Invalid")

    end sub





  • cpravincpravin Member Posts: 21
    : Hi
    : who we can check the password to make sure ti has only alphabetic characters nothing else.
    : Thank you
    :
    :

    Well you can write a validation function or inline code in the function to check whether each the characters in textbox are all aplhabetic. If any charatcer is not alphabetic then you can discard it.

    this can be done as follows


    VB.NET
    Public Sub CheckPassword(byval pass as string)
    dim i as integer
    dim flag as boolean = true

    for i=0 to i='A' and pass(i)<='Z' ) or _
    ( pass(i)>= 'a' and pass(i)<='z') ) then
    flag = false

    if flag then
    msgbox("Valid")
    else
    msgbox("Invalid")

    end sub





  • ziyadaldinziyadaldin Member Posts: 2
    : : Hi
    : : who we can check the password to make sure ti has only alphabetic characters nothing else.
    : : Thank you
    : :
    : :
    :
    : Well you can write a validation function or inline code in the function to check whether each the characters in textbox are all aplhabetic. If any charatcer is not alphabetic then you can discard it.
    :
    : this can be done as follows
    :
    :
    : VB.NET
    : Public Sub CheckPassword(byval pass as string)
    : dim i as integer
    : dim flag as boolean = true
    :
    : for i=0 to i='A' and pass(i)<='Z' ) or _
    : ( pass(i)>= 'a' and pass(i)<='z') ) then
    : flag = false
    :
    : if flag then
    : msgbox("Valid")
    : else
    : msgbox("Invalid")
    :
    : end sub
    :
    : Thank you for your reply but I need that to work in visual basic.NET .
    :
    :
    :
    :

  • MalazaMalaza Member Posts: 1
    Hi

    I`m Lucky a new member in Programmer`s Heaven!

    I don`t now if you got the answer to your question,But If you are using VB.NET reloaded book by Diane Zak.

    The answer is:"NB: This is the answer if you are using a Textbox and also your inputs must be in the uppercase else it won`t work"

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    If (e.KeyChar < "A" OrElse e.KeyChar > "Z") AndAlso e.KeyChar <> ControlChars.Back Then 'This Statement Accept only Capital Letters and Back space
    e.Handled = True
    End If
    End Sub
    LT Bebeza

Sign In or Register to comment.