Close

Results 1 to 16 of 16
  1. #1
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Visual studio.net help

    I have made up a program, but i want to set some boxes to accept just text and some to just numbers, anyknow how i go about this please? i am newbie by the way




    Nik

  2. #2
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default Re: Visual studio.net help

    web application? console application? windows application?

    do you want to limit the input, as the keyboard is typed or when they try to leave the input area?

    when you say just "text" do you mean alphabetic? or alphanumeric?

    which language are you programming in??? c#, vb.net, asp.net, j#?

    if you can answer these questions, then yes I can certainly help.

  3. #3
    DF VIP Member nitelife's Avatar
    Join Date
    Nov 2002
    Location
    Reading, Berks
    Posts
    1,170
    Thanks
    115
    Thanked:        13
    Karma Level
    337

    Default Re: Visual studio.net help

    The type of application would be useful too. (i.e Dialog, SDI/MDI etc.)

  4. #4
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    Quote Originally Posted by graham.edmon
    web application? console application? windows application?

    do you want to limit the input, as the keyboard is typed or when they try to leave the input area?

    when you say just "text" do you mean alphabetic? or alphanumeric?

    which language are you programming in??? c#, vb.net, asp.net, j#?

    if you can answer these questions, then yes I can certainly help.
    Language = Visual studio . net

    I want the input to be alphabetic and alphanumeric

    I do want to limit the input as it is a post code i am putting into the program, but this i am not really fussed about that part yet, i just want the text box to accept letters and numbers as it is a post code.

    I have found the following on a vb forum

    Private sub text1_keypress ( keyascii as integer)
    Select case keyascii
    Case vbkeyback
    Case vbkey0 to vbkey9
    Case vbkeya to vbkeyz

    keyasciii=0
    Case vbkeya + 32 to vbkeyz+32
    key ascii=0
    Case Else
    Key ascii=0

    End select
    End Sub

    I dunno if this is right or not, also as to where to input it in. As i have tried the post code text box code screen, and i get a shit loads of errors


    Thank you

    Nik

  5. #5
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default Re: Visual studio.net help

    Visual Studio .NET is a development environment, it isn't actually a language in its self. VS.NET allows multiple lanuages to be compile to run on a common run time, the CLR. so the languages are C#, VB.NET, etc etc..

    an example is attached.. and is written in c# as a windows application rather than a web application.. it has two levels of validation key level validation preventing you from pressing invalid keys and a regular expression to validate that the UK post code format is valid..

    P.S. the code example you have found is VB and not VB.NET, VB.NET is a complete new language which is based on the older VB but which implements the language completely differently.

  6. #6
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    Cheers mate will try it, thank you for the information about the code i posted before hand too. Will post feedback soon :-)


    cheers :thumbs


    Nik

  7. #7
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    i found out the textbox is in an array, i have got the code so the txtbox can accept both numbers and letters but i get a shite load of errors because it is in an array. Anyone how i can change this without pulling my hair out :|



    cheers

    Nik

  8. #8
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default Re: Visual studio.net help

    post your code here, and I will have a look at it...



    Quote Originally Posted by niky2k232
    i found out the textbox is in an array, i have got the code so the txtbox can accept both numbers and letters but i get a shite load of errors because it is in an array. Anyone how i can change this without pulling my hair out :|



    cheers

    Nik

  9. #9
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    Private Sub AddressList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddressList.SelectedIndexChanged
    Dim anAddress As Address
    anAddress = AddressList.SelectedItem

    txtName.Text = anAddress.Name
    txtAddress.Text = anAddress.Address
    txtCounty.Text = anAddress.County
    txtpost.Text = anAddress.Postcode
    txtTown.Text = anAddress.Town
    txtHomeTel.Text = anAddress.HomeTel
    txtOfficeTel.Text = anAddress.OfficeTel
    txtEmail.Text = anAddress.Email
    txtMob.Text = anAddress.Mobile
    btnUpdate.Enabled = False
    End Sub

    Private Sub frmAddress_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

    PopulateListBox()
    setSelect()
    setSomeButtonsTrue()
    btnSave.Enabled = False
    noItemsOnList()
    End Sub

    Private Sub noItemsOnList()
    ' Disables some buttons if the listbox is empty
    If AddressList.Items.Count < 1 Then
    btnDel.Enabled = False
    btnEdit.Enabled = False
    btnNew.Enabled = False
    btnCancel.Enabled = False
    btnUpdate.Enabled = False
    btnSave.Enabled = False
    End If
    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
    ClearBoxes()
    setSomeButtonsFalse()
    editFlag = False
    End Sub

    Private Sub ClearBoxes()
    txtName.Clear()
    txtAddress.Clear()
    txtCounty.Clear()
    txtpost.Clear()
    txtTown.Clear()
    txtHomeTel.Clear()
    txtOfficeTel.Clear()
    txtEmail.Clear()
    txtMob.Clear()
    txtName.Focus()
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
    editFlag = True


    setSomeButtonsFalse()
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
    ' Adds objects to the Arraylist and populates the listbox
    Try
    Dim anAddress As Address
    If editFlag Then
    anAddress = AddressList.SelectedItem
    Else
    anAddress = New Address

    End If

    anAddress.Name = txtName.Text
    anAddress.Address = txtAddress.Text
    anAddress.County = txtCounty.Text
    anAddress.Postcode = txtpost.Text
    anAddress.Town = txtTown.Text
    anAddress.HomeTel = txtHomeTel.Text
    anAddress.OfficeTel = txtOfficeTel.Text
    anAddress.Email = txtEmail.Text
    anAddress.Mobile = txtMob.Text

    If Not editFlag Then
    _AddressSys.AddAddress(anAddress)
    AddressList.Items.Add(anAddress).ToString()

    End If
    PopulateListBox()
    setSelect()
    setSomeButtonsTrue()
    btnSave.Enabled = True
    Catch ex As Exception
    MessageBox.Show("Please Enter Post Code", "Check Data", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Try
    End Sub

    Private Sub setSelect()
    If AddressList.Items.Count > 0 Then
    AddressList.SetSelected(0, True)
    End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
    PopulateListBox()
    setSelect()
    setSomeButtonsTrue()
    noItemsOnList()
    End Sub


    Private Sub setSomeButtonsTrue()
    btnEdit.Enabled = True
    btnDel.Enabled = True
    btnNew.Enabled = True
    BtnExit.Enabled = True
    btnUpdate.Enabled = False
    btnCancel.Enabled = False
    End Sub

    Private Sub setSomeButtonsFalse()
    btnEdit.Enabled = False
    btnDel.Enabled = False
    btnNew.Enabled = False
    'BtnExit.Enabled = False
    btnUpdate.Enabled = True
    btnCancel.Enabled = True

    End Sub

    Private Sub PopulateListBox()
    ' Add objects to the Listbox
    Dim i As Integer
    Dim anAddress As Address
    AddressList.Items.Clear()
    For i = 0 To _AddressSys.NumberOfpeople() - 1
    anAddress = _AddressSys.getAddress(i)
    AddressList.Items.Add(anAddress).ToString()
    Next
    End Sub

    Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
    Me.Close()
    End Sub

    Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
    ' Deletes objects from the Arraylist and Listbox
    Dim Ans As String
    Dim anAddress As Address

    anAddress = AddressList.SelectedItem
    Ans = MessageBox.Show("Are you sure you want to Delete item?", "Please Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Ans = vbYes Then
    _AddressSys.DeleteData(anAddress)
    PopulateListBox()
    setSelect()
    btnSave.Enabled = True
    If AddressList.Items.Count = 0 Then
    ClearBoxes()
    setSomeButtonsFalse()

    End If
    Else
    Exit Sub
    End If
    End Sub

    Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
    btnUpdate.Enabled = True
    btnCancel.Enabled = True
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    'Stores data as a serialized file
    _AddressSys.SaveData()
    btnSave.Enabled = False
    End Sub

    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click

    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub

    Private Sub AddressList_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddressList.TextChanged

    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

    End Sub

    Private Sub txtpost_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub txtpost_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub


    Private Sub txtCounty_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCounty.TextChanged

    End Sub

    Private Sub txtpost_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpost.TextChanged

    End Sub

    Private Sub txtpost_TextAlignChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpost.TextAlignChanged

    End Sub

    Private Sub txtpost_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpost.Resize

    End Sub

    Private Sub txtpost_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpost.Validated

    End Sub

    Private Sub txtpost_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtpost.Validating

    End Sub

    Private Sub txtpost_TabStopChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpost.TabStopChanged

    End Sub

    Private Sub txtpost_CausesValidationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpost.CausesValidationChanged

    End Sub
    End Class




    It is the txtpost textbox where i want it to accept numbers and letters.


    cheers


    Nik

  10. #10
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default Re: Visual studio.net help

    zip it up and attach it.. makes it easier to read, and debug.

  11. #11
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    ok ty

  12. #12
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default Re: Visual studio.net help

    ok will have a look @ it for you

  13. #13
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    ok cheers mate, soemone told me that i need to chnage the textbox from an array to a string, any thoughts?

    Thanks for your time bytheway :-)

    Nik

  14. #14
    Awaiting Email Confirm Thalamus's Avatar
    Join Date
    Dec 2002
    Location
    home
    Posts
    996
    Thanks
    75
    Thanked:        11
    Karma Level
    0

    Default Re: Visual studio.net help

    Use visual basic 6 m8 if your a beginner.

  15. #15
    DF VIP Member Nikki's Avatar
    Join Date
    Dec 2002
    Location
    Walsall
    Posts
    12,413
    Thanks
    559
    Thanked:        148
    Karma Level
    899

    Default Re: Visual studio.net help

    It gota be done in VB.NET dont ask me why its Edexcels fault!!

    I managed to sort this problem now with afew ideas off a few members off this board, i changed the textbox from an array to a string. Workis fine now :-)



    Thank you for all your responses tho much appreciated.


    Nik

  16. #16
    DF VIP Member graham.edmon's Avatar
    Join Date
    May 2001
    Location
    Edinburgh
    Posts
    263
    Thanks
    0
    Thanked:        0
    Karma Level
    290

    Default Re: Visual studio.net help

    Quote Originally Posted by niky2k232
    It gota be done in VB.NET dont ask me why its Edexcels fault!!

    I managed to sort this problem now with afew ideas off a few members off this board, i changed the textbox from an array to a string. Workis fine now :-)



    Thank you for all your responses tho much appreciated.


    Nik

Similar Threads

  1. Wanted: Visual Basic Latest/Full Edition
    By Ttocs in forum Buy, Sell and Trade
    Replies: 0
    Last Post: 21st November 2002, 02:35 PM
  2. Visual Basic 6
    By Digi Program in forum Website Coding & Graphics
    Replies: 2
    Last Post: 15th October 2002, 08:11 PM
  3. visual basic 6 enterprise
    By spade2001 in forum Programming
    Replies: 21
    Last Post: 14th September 2002, 10:51 AM
  4. Replies: 2
    Last Post: 13th September 2002, 06:48 PM
  5. Visual basic Any one!
    By magic1 in forum The Dog and Duck
    Replies: 2
    Last Post: 8th September 2002, 02:05 PM

Social Networking Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •