注册 登录
编程论坛 VB6论坛

vb如何实现text用回车键自动换行

vb小小白 发布于 2022-01-16 20:55, 1747 次点击
刚学vb,基础知识薄弱,我工作中有很多需要用科学计算器算工件参数,所以自己写了一个EXE文件,当然里面的语法有的是百度来的,语法可能会出臃肿。目前程序写好了而且好用,就是想能不能实现text1输入数值后回车自动跳到text2,然后到依次到text4,,后面的都是计算结果,下面我附上我的代码,希望高手帮忙点拨或者直接给我代码也行,按照我原有的代码基础上,非常感谢!
Private Sub Command1_Click()
Dim m As Single, da As Single, ha As Single, z As Single
Dim tn As Single, de As Single, λ As Single
pai = 3.14159265358979
m = Val(Text1.Text)
de = Val(Text6.Text)
z = Val(Text4.Text)

tn = m * pai
Text5.Text = tn
Text5.Text = FormatNumber(tn, 6)

da = Text2.Text
ha = Text3.Text
de = da - ha * 2
Text6.Text = de
   
Dim a As Double
a = m / de
Text9.Text = a
Text9.Text = Format(a, "0.##########")
Text7.Text = (Atn(a / Sqr(-a * a + 1))) * 180 / pai * z
Text7.Text = FormatNumber(Text7.Text, 6)
Text8.Text = (1 / (Cos(Text7.Text * pai / 180))) * tn
Text8.Text = FormatNumber(Text8.Text, 6)

Dim total As String
λ = Val(Text7.Text)
dd = Fix(λ)
'Print dd  '-8
If dd - λ < 0.000001 Then λ = λ + 0.000001
dou = Fix(λ)
'Print dou '8
fen = Fix((λ - dou) * 60)
'Print fen  '-14
miao = ((λ - dou) * 60 - fen) * 60
ooo = Abs(miao)
If (ooo * 10) Mod 10 = 0 Then
  txtmiao = Format(ooo, "00") + """"
 Else
  txtmiao = Format(ooo, "00") + """"
End If
'Print txtmiao
total = CStr(dou) + "°" + Format(Abs(fen) + "00") + "′" + txtmiao
If λ < 0 Then total = "-" & total
Text12.Text = total

End Sub
3 回复
#2
apull2022-01-16 23:32

程序代码:

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        Text2.SetFocus
    End If
End Sub

其他几个text一样。
#3
vb小小白2022-01-17 17:52
回复 2楼 apull
太感谢了,非常好用
#4
独木星空2022-01-18 06:43
回复 楼主 vb小小白
每一个问题的提出,和解答,都能使人向前迈进一步。
1