| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2771 人关注过本帖
标题:VB中如何解决浮点问题?
只看楼主 加入收藏
hyhhd
Rank: 2
等 级:论坛游民
威 望:1
帖 子:502
专家分:44
注 册:2006-5-12
收藏
得分:0 

试试这个:
Option Explicit


''''''''''将度转化程度分秒''''

Private Function DegreeToDMS( _
strDegree As String _
) As Double

Dim Msg As String
Dim V1 As Double
Dim V2 As Double
Dim V3 As Double
Dim i As Integer
Dim j As Integer
Dim L As Integer
Dim Temp As String
Dim Temp1 As String
Dim Temp2 As String
Dim Temp3 As String

Msg = strDegree
L = Len(Msg)

' V1 = Val(Msg)

For i = 1 To L
Temp = Mid$(Msg, i, 1)
If Temp = "°" Then
Temp1 = Mid$(Msg, 1, i - 1)
j = i + 1

ElseIf Temp = "'" Then
Temp2 = Mid$(Msg, j, i - 1)
Temp3 = Mid$(Msg, i + 1, L)
Exit For

Else

End If

Next

V1 = Val(Temp1)
V2 = Val(Temp2) / 60
V3 = Val(Temp3) / 3600

DegreeToDMS = V1 + V2 + V3

End Function

Private Sub Command1_Click()
Text2 = DegreeToDMS(Text1)

End Sub

[此贴子已经被作者于2007-2-8 21:06:55编辑过]


2007-02-08 21:04
wudimp
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-12-19
收藏
得分:0 
TO:hyhhd
首先认个老乡,我也是宝鸡的
你这个方法原理上是通过查找度分秒的符号来分别提取度和分,秒的数值,实验后好象有点问题,需要调试下.
2007-02-10 15:58
快速回复:VB中如何解决浮点问题?
数据加载中...
 
   



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

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