|
-
Feb 22nd, 2000, 05:20 AM
#1
Thread Starter
New Member
I am trying to build a function so that when
certain keys are pressed the focus will shift
Ex.
If I have focus in Text1 and I want to move Text3 the I just press my hot key. If I am in three and I press my other hot key focus will go to Text2
Just need this for my three Textboxes
Here is the code
Private Sub Command1_Click()
Dim DepCost As Double, DepSalvalge As Double, DepLife As Double, i As Double
Dim Answer As String, nl As String
Dim Dan As Integer, m As Integer
Dim DepSln, DepDdb, DepSyd
nl = Chr$(13) + Chr$(10)
m = 1
Call KeyPress
Call ImputData(DepCost, DepSalvalge, DepLife)
DepSln = SLN(DepCost, DepSalvalge, DepLife)
DepSln = Format(DepSln, "Currency")
Answer = Answer & " " & DepSln & nl
For j = m To DepLife
DepDdb = DDB(DepCost, DepSalvalge, DepLife, j)
DepDdb = Format(DepDdb, "$#,###.##")
Answer = Answer & " " & DepDdb & nl
Next j
m = 1
For j = m To DepLife
DepSyd = SYD(DepCost, DepSalvalge, DepLife, j)
DepSyd = Format(DepSyd, "$#,###.##")
Answer = Answer & " " & DepSyd & nl
Next j
Text4 = Answer
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "Cost = "
Label2.Caption = "salvage = "
Label3.Caption = "life = "
Label1.FontBold = True
Label2.FontBold = True
Label3.FontBold = True
Label1.Alignment = 2
Label2.Alignment = 2
Label3.Alignment = 2
End Sub
Private Sub ImputData(DepCost As Double, DepSalvalge As Double, DepLife As Double)
DepCost = Val(Text1.Text)
DepSalvalge = Val(Text2.Text)
DepLife = Val(Text3.Text)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyF2 Then
Text1.SetFocus
KeyAscii = 0
Else
KeyAscii = 0
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyF3 Then
Text2.SetFocus
Else
End If
End Sub
Now this code just accepts value from Text1, Text2 and Text3 then Calculates depreciation methods and prints them to text box.
Thanks
Coco
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|