Novice question on KeyPress 
Author Message
 Novice question on KeyPress

I finally figure it out, and here is the code if anyone
else is looking.  I was surprised to see that VB.Net does
not seem to care whether something is a integer or a
string.  I did it with conversions at first, but then
figure out that VB does not seem to care, and will add
numbers in text and integer form.  Can't decide if I like
that or not... :)
'=================================
 Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox2.Text = 0

    End Sub

    Private Sub Form1_KeyPress(ByVal sender As Object, _
        ByVal e As KeyPressEventArgs) Handles
MyBase.KeyPress
        Counter1 = TextBox2.Text
        If (e.KeyChar = "e") Then
            TextBox2.Text = TextBox2.Text + 1
            e.Handled = True
        End If
    End Sub
 '==============================



Wed, 26 Jan 2005 11:10:49 GMT  
 Novice question on KeyPress
Actually VB.NET does care if you add strings or integers... if you tell it
to.  At the top of the file with your form in it, add the statement

Option Strict On

Then try to compile your form....

HTH

David


Quote:
> I finally figure it out, and here is the code if anyone
> else is looking.  I was surprised to see that VB.Net does
> not seem to care whether something is a integer or a
> string.  I did it with conversions at first, but then
> figure out that VB does not seem to care, and will add
> numbers in text and integer form.  Can't decide if I like
> that or not... :)
> '=================================
>  Private Sub Form1_Load(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles MyBase.Load
>         TextBox2.Text = 0

>     End Sub

>     Private Sub Form1_KeyPress(ByVal sender As Object, _
>         ByVal e As KeyPressEventArgs) Handles
> MyBase.KeyPress
>         Counter1 = TextBox2.Text
>         If (e.KeyChar = "e") Then
>             TextBox2.Text = TextBox2.Text + 1
>             e.Handled = True
>         End If
>     End Sub
>  '==============================



Wed, 26 Jan 2005 11:52:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Novice Ref Question

2. question from an Access novice

3. Creating User Forms - Novice question

4. Question from VBA novice re True and False values in VBA code for Word97

5. Unable to return ouput parameters to VB.net component - novice question

6. Return values from VB.net component - Novice Question

7. VB Interface Implementation - Novice Question

8. question from novice: Superscripting

9. DAO novice questions

10. Novice question about Stored Procedures

11. Novice needs help with Dynaset question

12. Question from a Novice

 

 
Powered by phpBB® Forum Software