20-06-13, 07:08 PM
السلام عليكم
لن اضيف الكثير على ما فعله الاخ Aly El-Haddad
وقد اضفت عليه متغيرين ايضا
علما بانك يجب ان تضغط مرة اخرى على صندوق النص الذي تريد الاضافة عليه لانه قد الغي التركيز عليه واصبح على الزر
لن اضيف الكثير على ما فعله الاخ Aly El-Haddad
وقد اضفت عليه متغيرين ايضا
علما بانك يجب ان تضغط مرة اخرى على صندوق النص الذي تريد الاضافة عليه لانه قد الغي التركيز عليه واصبح على الزر
إقتباس :Public Class Form1
Private txt1 As Boolean = False
Private txt2 As Boolean = False
Private hLastCtrl As New IntPtr
Dim X As Integer
Dim Yy As Integer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For Each C As Control In Me.Controls
AddHandler C.Leave, AddressOf SetLastFocusedControl
Next
End Sub
Private Sub SetLastFocusedControl(ByVal sender As System.Object, ByVal e As System.EventArgs)
hLastCtrl = sender.Handle
End Sub
Private Sub TextBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Enter
txt2 = False
txt1 = True
End Sub
Private Sub TextBox2_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Enter
txt1 = False
txt2 = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (hLastCtrl = TextBox1.Handle) AndAlso txt1 Then
TextBox1.Text &= "1" 'or TextBox1.Text =TextBox1.Text & "1"
txt1 = False
End If
If (hLastCtrl = TextBox2.Handle) AndAlso txt2 Then
TextBox2.Text &= "1" 'or TextBox2.Text =TextBox2.Text & "1"
txt2 = False
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If (hLastCtrl = TextBox1.Handle) AndAlso txt1 Then
X = Val(TextBox1.Text)
TextBox1.Text = X + 1
txt1 = False
End If
If (hLastCtrl = TextBox2.Handle) AndAlso txt2 Then
Yy = Val(TextBox2.Text)
TextBox2.Text = Yy + 1
txt2 = False
End If
End Sub
End Class
