CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Adding Letters

  1. #1
    Join Date
    May 2004
    Posts
    42

    Adding Letters

    I have and application that requires me to add letters. So if I have an A I need the next values to be B and so on. Any ideas how this works. I am using a text box to store me letter.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    10,831

    Re: Adding Letters

    You could try this Nate :
    Code:
    Public Class Form1
    
        Private strEnteredLet As String 'get entered letter
        Private kEnteredKeyCode As Integer 'get keycode of entered letter
        Private strAddLet As String 'get key code of following ( next ) letter
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            TextBox1.SelectionStart = 2 'start selection here
            TextBox1.SelectedText = strAddLet 'add this in selection
        
        End Sub
    
        Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            strEnteredLet = TextBox1.Text 'store entered text 
            kEnteredKeyCode = e.KeyCode + 1 'get next keycode
            strAddLet = ChrW(kEnteredKeyCode) 'convert to readable format ( otherwise will show number, not letter )
    
        End Sub
    
    End Class
    Once I click on a button, the next letter in the sequence will show
    I've also assumed that you wanted only Uppercase letters, so I set my CharacterCasing property of my textbox to Uppercase.

    I hope it helps!

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
  •  



HTML5 Development Center

Click Here to Expand Forum to Full Width