社区
ASP
帖子详情
各位帮帮忙,急急急。。。n5=cdbl(n1*n2+n3+n4) and 65535,当n1*n2+n3+n4太大时报溢出?
yyb2000
2000-07-03 10:33:00
...全文
138
6
打赏
收藏
各位帮帮忙,急急急。。。n5=cdbl(n1*n2+n3+n4) and 65535,当n1*n2+n3+n4太大时报溢出?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Un1
2000-07-04
打赏
举报
回复
使用and时,vb会自动做clng和cbool转换,如果double值大于&h7fffffff或小于&h80000000当然要出错。
yyb2000
2000-07-04
打赏
举报
回复
liyang:
如下不能通过
dim a,b as double
a=65535# * 65535#
b=myand(a,65535)
liyang
2000-07-03
打赏
举报
回复
只好自己写一个
Private Function MyAnd(ByVal varSour As Variant, ByVal varMod As Variant) As Long
Dim I As Long
Dim bytTemp() As Byte
Dim dblRem As Double, dblRem2 As Double
Dim lResult As Long
Dim lReturn As Long
Dim n3 As Double
Dim lModLen As Long
ReDim bytTemp(0)
dblRem = varSour
Do Until dblRem < 2
dblRem2 = Int(dblRem / 2)
bytTemp(UBound(bytTemp)) = dblRem - dblRem2 * 2
ReDim Preserve bytTemp(UBound(bytTemp) + 1)
dblRem = dblRem2
Loop
bytTemp(UBound(bytTemp)) = dblRem
Dim bytMod() As Byte
Dim dblTemp1 As Double, dblTemp As Double
ReDim bytMod(0)
dblTemp = varMod
Do Until dblTemp < 2
dblTemp1 = Int(dblTemp / 2)
bytMod(UBound(bytMod)) = dblTemp - dblTemp1 * 2
ReDim Preserve bytMod(UBound(bytMod) + 1)
dblTemp = dblTemp1
Loop
bytMod(UBound(bytMod)) = dblTemp
lModLen = UBound(bytMod)
For I = 0 To IIf(UBound(bytTemp) > lModLen, lModLen, UBound(bytTemp))
lResult = lResult Or bytTemp(I) * 2 ^ I
Next I
MyAnd = lResult And varMod
End Function
yyb2000
2000-07-03
打赏
举报
回复
我早试过,不行,
n5=cdbl(n1)*cdbl(n2)+cdbl(n3)+cdbl(n4) 时不会报错,一但
n5=(cdbl(n1)*cdbl(n2)+cdbl(n3)+cdbl(n4)) and 65535,wrong?
liyang
2000-07-03
打赏
举报
回复
是这样:cdbl(n1)*cdbl(n2)+cdbl(n3)+cdbl(n4),即把每个变量均转化为不超限制的类型。
liyang
2000-07-03
打赏
举报
回复
你的 n1,n2,n3,n4是何类型。可以n1#*n2#+n3#+n4#,把每一个转化为double
VB加法器 一个数加另一个数.rar
VB加法器功能源码,类似于计算器,输入一个加数和另一个加数,会计算出结果。编写时,先定义两个数,定义好之后,用下面的代码进行加法计算,是一个较简单的Vb初级数学计算例子: Private Sub Command2_Click() num1 =
CDbl
(Text2.Text) num2 =
CDbl
(Text3.Text) sum = num1 num2 Text1.Text = CStr(sum) End Sub 最终的运行效果如截图所示,你可以再扩展出减法或乘除法,编写出计算器程序。
广东发展银行信用卡利息计算工具(含VB源码)
VB写的计算广发行信用卡提现手续费及利息的小工具,不包含滞纳金的计算! 广发银行提现手续费按2.5%收取,最低10元!按万分之五收取日息!而且是利滚利的计算方式! 还是在这把代码贴出来吧(手续费是按2.5%收的,之前搞成了3%,更正后的代码如下)! Private Sub Command1_Click() Label4.Caption = "" If Not IsNumeric(Text1.Text) Then MsgBox "提现金额只能为数字!请重新输入!", vbOKOnly + vbInformation, "提示!": Text1.SetFocus: Exit Sub If Not IsNumeric(Text2.Text) Then MsgBox "还款天数只能为数字!请重新输入!", vbOKOnly + vbInformation, "提示!": Text2.SetFocus: Exit Sub Dim TX As Double, SXF As Double, TS As Double, LXR As Double, LX As Double, RS As Double TX =
CDbl
(Text1.Text) TS =
CDbl
(Text2.Text) 'If TX <= 0 Or (TX Mod 100) <> 0 Then MsgBox "提现金额必须大于零且为100的倍数!", vbOKOnly + vbInformation, "提示!": Text1.SetFocus: Exit Sub If TX <= 0 Then MsgBox "提现金额必须大于零!", vbOKOnly + vbInformation, "提示!": Text1.SetFocus: Exit Sub If TS <= 0 Then MsgBox "天数必须为大于零的正整数!", vbOKOnly + vbInformation, "提示!": Text2.SetFocus: Exit Sub If TS > Fix(TS) Then TS = Fix(TS) + 1: Text2.Text = CStr(TS) Else TS = Fix(TS): Text2.Text = TS '天数取整 SXF = TX * 0.025 If SXF < 10 Then SXF = 10 Else SXF = Round(SXF, 2) '手续费最低收取10RMB,小数部分保留两位 Dim i As Double LXR = TX For i = 1 To TS Step 1 LX = LXR * 0.0005 LXR = LXR + LX Next i If (LXR - TX) < 1 Then LX = 1 Else LX = Round(LXR - TX, 2) '利息最低收取1RMB RS = TX + SXF + LX '应还金额为:提现金额+手续费+利息 Text3.Text = CStr(RS) Label4.Caption = "其中包含手续费:" & CStr(SXF) & " RMB 利息:" & CStr(LX) & " RMB" Label4.Left = Me.Width / 2 - Label4.Width / 2 Text1.SetFocus End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then MsgBox "广发银行提现手续费按2.5%收取,最低10元!" & vbCrLf & vbCrLf & "按万分之五收取日息!利滚利的计算方式!(最低1RMB)" End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 27 Then Unload Me End Sub Private Sub Form_Load() lblShow.Caption = "广发行提现手续费按2.5%收取(最低10RMB)!" & vbCrLf & vbCrLf & "按万分之五收取日息!利滚利的计算方式!(最低1RMB)" lblShow.Left = Me.Width / 2 - lblShow.Width / 2 Label4.Left = Me.Width / 2 - Label4.Width / 2 Me.Left = Screen.Width / 2 - Me.Width / 2 Me.Top = Screen.Height / 2 - Me.Height / 2 End Sub Private Sub Text1_GotFocus() If Len(Text1.Text) > 0 Then Text1.SelStart = 0: Text1.SelLength = Len(Text1.Text) End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If Trim(Text1.Text) <> "" And KeyAscii = 13 Then Text2.SetFocus End Sub Private Sub Text2_GotFocus() If Len(Text2.Text) > 0 Then Text2.SelStart = 0: Text2.SelLength = Len(Text2.Text) End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" And KeyAscii = 13 Then Command1_Click End Sub
一个有趣的VB小程序
Private Sub Command1_Click() 'On Error GoTo err Dim line_all As Double Dim jgtemp As String Dim jg As String Dim line_zensu As Integer Dim dot As Integer Dim zensu As Integer Dim mon As String 'If Me.MaskEdBox1.Text <> "." Then line_all =
CDbl
(Me.Text1.Text) mon = CStr(line_all) line_all = Len(mon) dot = InStr(mon, ".") line_zensu = line_all - dot If (line_all - dot) < 2 Then mon = mon & "0" 'MsgBox CStr(line_all) & CStr(dot) 'MsgBox mon For i = 0 To line_all - 1 ' ' If i < line_all - 1 Then word = Mid(mon, line_all - i, 1) ' Else ' word = Mid(mon, line_all, 1) ' End If If word <> "." Then 'word = Mid(mon, i, 1) jg = retur
n2
(i + 1) & jg jg = retur
n1
(word) & jg jgtemp = jg & jgtemp 'Else: i = i - 1 ' End If End If Next i MsgBox jg Exit Sub 'End If err: 'MsgBox err.Number If err.Number = 13 Then MsgBox "非法字符", vbExclamation Exit Sub End Sub Function retur
n1
(s As String) As String retur
n1
= zw(CInt(s)) End Function Function retur
n2
(d As Integer) As String If i < 3 Then retur
n2
= dw(d - 1) Else retur
n2
= dw(d - 2) End If End Function
根据经纬度计算图幅号
'计算图幅号 Option Explicit Type ArrayData Data() As String Count As Integer End Type Public Function getSheetNumber(strLat As String, strLon As String, ScaleID As String) As String Dim strLatErr As String, strLonErr As String Dim dblLatErr As String, dblLonErr As String Dim dblLat As Double, dblLon As Double Dim a As String, b As Integer, c As Integer, d As Integer Select Case ScaleID Case "A" '1:100W strLatErr = "4°00′00″": strLonErr = "6°00′00″" Case "B" '1:50W strLatErr = "2°00′00″": strLonErr = "3°00′00″" Case "C" '1:25W strLatErr = "1°00′00″": strLonErr = "1°30′00″" Case "D" '1:10W strLatErr = "00°20′00″": strLonErr = "00°30′00″" Case "E" '1:5W strLatErr = "00°10′00″": strLonErr = "00°15′00″" Case "F" '1:2.5W strLatErr = "00°05′00″": strLonErr = "00°07′30″" Case "G" '1:1W strLatErr = "00°02′30″": strLonErr = "00°03′45″" Case "H" '1:0.5W strLatErr = "00°01′15″": strLonErr = "00°01′52.5″" Case Else ' getSheetNumber = "比例尺代码错误" Exit Function End Select dblLatErr = changeToSecond(strLatErr): dblLonErr = changeToSecond(strLonErr) dblLat = changeToSecond(strLat): dblLon = changeToSecond(strLon) a = Chr(64 + Int(dblLat / changeToSecond("4°00′00″")) + 1) b = Int(dblLon / changeToSecond("6°00′00″") + 31) If ScaleID <> "A" Then c = changeToSecond("4°00′00″") / dblLatErr - Int(mMod(dblLat, changeToSecond("4°00′00″")) / dblLatErr) d = Int(mMod(dblLon, changeToSecond("6°00′00″")) / dblLonErr) + 1 getSheetNumber = a & b & ScaleID & Format(c, "000") & Format(d, "000") Else getSheetNumber = a & b End If End Function Private Function changeToSecond(strDeg As String) As Double Dim intD As Integer, intM As Integer, dblS As Double intD = Int(strOperate(strDeg, "°").Data(0)) dblS =
CDbl
(Left(strOperate(strDeg, "′").Data(1), Len(strOperate(strDeg, "′").Data(1)) - 1)) intM = Int(Left(strOperate(strDeg, "°").Data(1), 2)) changeToSecond = intD * 60 + intM + dblS / 60 End Function Private Function strOperate(ByVal strX As String, ByVal strA As String) As ArrayData '分割字符串 Dim i As Integer, j As Integer, k As Integer Dim cnt As Integer, strTemp As String If Trim(strA) <> "" Then strX = Trim(strX) strA = Trim(strA) strX = strX & strA For i = 1 To Len(strX) If Mid(strX, i, Len(Trim(strA))) = strA Then cnt = cnt + 1 i = i + Len(strA) - 1 End If Next i strOperate.Count = cnt ReDim strOperate.Data(cnt - 1) For j = 1 To Len(strX) If Mid(strX, j, Len(strA)) = strA Then strOperate.Data(k) = Left(strX, j - 1) strX = Trim(Right(strX, Len(strX) - Len(strOperate.Data(k)) - Len(strA))) k = k + 1 j = 0 End If Next j Else strX = Trim(strX) strTemp = strX For i = 1 To Len(strTemp) If Mid(strTemp, i, 1) = " " Then cnt = cnt + 1 strTemp = Trim(Right(strTemp, Len(strTemp) - i + 1)) i = 0 End If Next i strX = strX & " " strOperate.Count = cnt + 1 ReDim strOperate.Data(cnt) For i = 1 To Len(strX) If Mid(strX, i, 1) = " " Then strOperate.Data(j) = Left(strX, i - 1) strX = LTrim(Right(strX, Len(strX) - i + 1)) j = j + 1 i = 0 End If Next i End If End Function Private Function mMod(dblF As Double, dblS As Double) As Double Dim intM As Integer intM = Int(dblF / dblS) mMod = dblF - dblS * intM End Function Private Sub Form_Load() Text1 = getSheetNumber("39°22′30″", "114°33′45″", "A") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "B") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "C") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "D") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "E") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "F") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "G") Text1 = Text1 & vbCrLf & getSheetNumber("39°22′30″", "114°33′45″", "H") End Sub
网站设计asp,sql
包括前台后台 <% Head="以下是您所选购的物品清单" ProductList = Session("ProductList") If Len(ProductList) = 0 Then Response.Redirect "Nothing.asp" DbPath = SERVER.MapPath("gw.mdb") Set conn = Server.CreateObject("ADODB.Connection") conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DbPath & ";PWD='sa';UID=''" If Request("MySelf") = "Yes" Then ProductList = "" Products = Split(Request("spID"), ", ") For I=0 To UBound(Products) PutToShopBag Products(I), ProductList Next Session("ProductList") = ProductList End If sql = "Select * From sp Where trim(spID) In (" & ProductList & ") Order By spID" Set rs = conn.Execute( sql ) %>
<%=Head%>
<%=Head%>
取消
商品编号
商品名称
单价
数量
总价
商品简介
<% Sum = 0 While Not rs.EOF Quatity = CInt( Request( "Q_" & rs("spID")) ) If Quatity <= 0 Then Quatity = CInt( Session(rs("spID")) ) If Quatity <= 0 Then Quatity = 1 End If Session(rs("spID")) = Quatity Sum = Sum +
CDbl
(rs("Price")) * Quatity %>
" Checked>
<%=rs("spID")%>
<%=rs("spName")%>
<%=rs("Price")%>
" Value=<%=Quatity%> Size=3>
<%=
CDbl
(rs("Price"))*Quatity%>
<%=rs("spnote")%>
<% rs.MoveNext Wend %>
总价格=<%=Sum%>
提交订单
退回所有物品
<% ListCategory conn %>
ASP
28,391
社区成员
357,060
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章