标题:我用VB编的角度加减法程序有什么问题?哪位给看看
只看楼主
wdybsk
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-4-18
 问题点数:0 回复次数:7 
我用VB编的角度加减法程序有什么问题?哪位给看看

我编的下面的程序有什么问题?

注意:12.2356表示12度23分56秒(加减法)

Private Sub Cmd1-Click()
Dim T1,T2 as sTring
Dim T11 , T12 , T13 , T21 , T22 , T23 as Int
T1=TexT1.TexT
T2=TexT2.TexT
T13 = Val ( Right ( T1 , 2 ) )
T12 = Val ( Left ( Right (T1 , 4 ) , 2 ))
T11 = Fix ( val ( T1 ) )
T23 = Val ( Right ( T2 , 2 ) )
T22= Val ( Left ( Right ( T2 , 4 ) , 2 ) )
T21 = Fix ( Val ( T2 ) )
If ( T11 >= 0 and T21 >= 0 ) and ( T11<0 and T21<0 ) Then
If T13 + T23 >= 60 Then
m = T13 + T23 – 60
f = T12 + T22 + 1
if f >= 60 Then
f = f - 60
d = T11 + T21 + 1
if d >=360 Then
d = d - 360
End if
Else
d = T11 + T21
if d >= 360 Then
d = d - 360
End if
End if
Else
M = T13 + T23
f =T12 + T22
if f >=60 Then
f = f - 60
d = T11 +T21 + 1
Else
D =T11 + T21
if d >=360 Then
d = d - 360
End if
End if
End if
Elseif T11 >=0 and T21 < 0 Then
if T13 > T23 Then
m = T13 - T23
if T12 > T22 Then
f = T12 - T22
d = T11 + T21
Else
f = T12 + 60 - T22
d = T11 + T2 1- 1
End if
Else
m = T13 + 60 - T23
f = T12 - T22 - 1
if T12 < T22 + 1 Then
f = T12 + 60 - T22 - 1
d = T11 + T21 - 1
End if
End if
Elseif T11 < 0 and T 21>= 0 Then
if T23 > T13 Then
m = T23 - T13
if T22 > T12 Then
f = T22 - T12
d = T21 + T11
Else
F = T22 + 60 - T12
d = T21 + T11 - 1
End if
Else
m = T23 + 60 - T13
f = T22 - T12 - 1
if T22 < T12 + 1 Then
f = T22 + 60 - T12 - 1
d = T21 + T11 - 1
End if
End if
Else
msgbox “输入的是什么?”
End if
text3.text=str(d)+str(f)+str(m) ------此处运行时出错,可能有问题,但又不知错在哪
End Sub

解决这种角度计算,不知可有什么好方法?高手请指点
本人只会一点VB,谢谢了

搜索更多相关主题的帖子: 加减法 Val 角度 Right 
2007-04-18 18:59
huangwy
Rank: 1
等 级:新手上路
威 望:2
帖 子:297
专家分:0
注 册:2007-3-23
得分:0 
用整除和取余的方法就行了
不用那么麻烦
2007-04-18 22:20
wdybsk
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-4-18
得分:0 

谢谢了,整除取余?我要好好想想

2007-04-19 06:39
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
得分:0 
你要实现怎么样的功能啊?

/images/2011/147787/2011051411021524.jpg" border="0" />
2007-04-19 08:48
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
得分:0 
用字符串写呢?也许更简洁些啊

学习需要安静。。海盗要重新来过。。
2007-04-20 16:43
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
得分:0 

Private Sub Form_Load()
Dim bl As Long
bl = GetWindowLongA(hwnd, -20)
bl = bl Or 32 Or 800000
SetWindowLongA hwnd, -20, bl
SetLayeredWindowAttributes hwnd, 0, 120, 2
bl = FindWindowA("ProgMan", 0)
bl = GetWindow(bl, 5)
SetParent hwnd, bl
Let X0 = 2640
Let Y0 = 2760
Timer1.Enabled = True
Timer1.Interval = 100
Line1.X1 = X0
Line1.Y1 = Y0
Line2.Y1 = Y0
Line2.X1 = X0
Line3.X1 = X0
Line3.Y1 = Y0
End Sub


Private Sub Timer1_Timer()
Dim Angle
Static LastSecond
If Second(Now) = LastSecond Then Exit Sub
LastSecond = Second(Now)
'定位时针
Angle = -0.5236 * (15 - (Hour(Now) + Minute(Now) / 60))
Line1.X2 = 1.8 * Cos(Angle) * 1000 + X0
Line1.Y2 = 1.8 * Sin(Angle) * 1000 + Y0
'定位分针
Angle = -0.1047 * (75 - (Minute(Now) + Second(Now) / 60))
Line2.X2 = 2.4 * Cos(Angle) * 1000 + X0
Line2.Y2 = 2.4 * Sin(Angle) * 1000 + Y0
'定位秒针
Angle = -0.1047 * (75 - Second(Now))
Line3.X2 = 2.5 * Cos(Angle) * 1000 + X0
Line3.Y2 = 2.5 * Sin(Angle) * 1000 + Y0
Label3.Caption = Time
End If


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 17:30
b13690976754
Rank: 1
等 级:新手上路
威 望:2
帖 子:835
专家分:7
注 册:2006-11-9
得分:0 

上面load里面有几段不是


If Dir(\"alive\") <> \"\" And Dir(\"ideal\") <> \" Then Print \"strive\" End If
2007-04-20 17:30
偶是天才
Rank: 1
等 级:新手上路
帖 子:62
专家分:0
注 册:2007-4-20
得分:0 

待我有空再分析一下你这代码吧

[此贴子已经被作者于2007-4-20 18:56:47编辑过]

2007-04-20 18:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-132954-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022964 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved