同 意关于“6 溢出错误” 我也遇见过 dim a as long a=3600*24 '溢出 a=86400 '不溢出 为什么????????????? 搞不懂 高手指点
在string的最后加个vbnullstring 试试至于ChinaSunFire(什么的什么还是什么) 的问题,msdn上有解释 You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer. For example: Dim x As Long x = 2000 * 365 ' Error: Overflow To work around this situation, type the number, like this: Dim x As Long x = CLng(2000) * 365
TO ChinaSunFire(什么的什么还是什么) 这个问题可以这样: dim a as long a=3600&*24& 因为VB默认的数据是Integer的,超过了(65536/2-1 我忘了多大了)当然溢出了。
To dbcontrols(泰山__抛砖引玉) 顺便帮忙看看问题呀!解决了给大分。多谢。
我彻底败了~~~~~没想到问题在这里: dim r as integer 而shellexecute返回的是long于是就溢出了~~~~~~我靠,这种错误……多谢ChinaSunFire(什么的什么还是什么) 提醒我。
首先我在VB6下用没有什么问题,不过你的程序应该改一下吧! 如下: Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Form_Load() ExecCmd "cmd.exe", , , True End Sub Public Sub ExecCmd(ByVal szCmd As String, Optional ByVal szParam As String = vbNullString, Optional ByVal szOperation As String = "open", Optional ByVal IsSubSystem As Boolean = False) Dim r As Integer r = ShellExecute(0, szOperation, szCmd, szParam, "", 5) '这里总是溢出! If r < 31 Then If IsSubSystem Then 'msgbox End If ElseIf r = 31 Then r = ShellExecute(0, szOperation, szCmd, "openas", "", 5) End If End Sub 因为VB6没问题,我马上想到这可能是VB5的一个BUG,查了一查,果然是VB5的 大BUG!!!! 可详见MSDN中的Article ID: Q171837 主要因为是因为对IF语句的处理有问题,请装SP2,还是用VB6吧! CAUSE Visual Basic does not evaluate Byte data type correctly in the if expression when compiled to Native code with optimizations. RESOLUTION Install Visual Studio 97 Service Pack 2 (SP2). The problem can also be addressed by compiling to P-code, compiling to Native Code with no optimizations, or using a data type other than the byte data type in the if expression.
能解释一下吗?很奇怪。
补充:我用的是VB5不过多谢tg123,我先试试另外我想晚点结帐,开着这个帖子,呵呵
你的问题,我来试试,不过好久没用VB5了。
我也遇见过
dim a as long
a=3600*24 '溢出
a=86400 '不溢出
为什么?????????????
搞不懂
高手指点
You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer. For example:
Dim x As Long
x = 2000 * 365 ' Error: Overflow
To work around this situation, type the number, like this: Dim x As Long
x = CLng(2000) * 365
这个问题可以这样:
dim a as long
a=3600&*24&
因为VB默认的数据是Integer的,超过了(65536/2-1 我忘了多大了)当然溢出了。
顺便帮忙看看问题呀!解决了给大分。多谢。
dim r as integer
而shellexecute返回的是long于是就溢出了~~~~~~我靠,这种错误……多谢ChinaSunFire(什么的什么还是什么) 提醒我。
如下:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Form_Load()
ExecCmd "cmd.exe", , , True
End Sub
Public Sub ExecCmd(ByVal szCmd As String, Optional ByVal szParam As String = vbNullString, Optional ByVal szOperation As String = "open", Optional ByVal IsSubSystem As Boolean = False)
Dim r As Integer
r = ShellExecute(0, szOperation, szCmd, szParam, "", 5)
'这里总是溢出!
If r < 31 Then
If IsSubSystem Then
'msgbox
End If
ElseIf r = 31 Then
r = ShellExecute(0, szOperation, szCmd, "openas", "", 5)
End If
End Sub
因为VB6没问题,我马上想到这可能是VB5的一个BUG,查了一查,果然是VB5的
大BUG!!!!
可详见MSDN中的Article ID: Q171837
主要因为是因为对IF语句的处理有问题,请装SP2,还是用VB6吧!
CAUSE
Visual Basic does not evaluate Byte data type correctly in the if expression when compiled to Native code with optimizations.
RESOLUTION
Install Visual Studio 97 Service Pack 2 (SP2). The problem can also be addressed by compiling to P-code, compiling to Native Code with no optimizations, or using a data type other than the byte data type in the if expression.
,不过MSDN是为C写的,所以这里的Integer应该是C中的int, 仍是现在的平台
上仍是32位,所以对应的应该是Long,不过由于返回的错误值不大,是不会引
起Overflow的。谢谢你的分,这种问题以后还是先看盾MSDN先,呵呵,否则分也太容易赚了。
这个问题比较难,还是问微软吧。
http://www.MintMail.com/?m=2210364
到 我的问题
选择 要加分的贴子 那一栏的 管理。
在 每个回复的人的ID 那一栏 有个文本框,输入分数
在 密码 文本框(贴子的上部)中输入密码,点击 给分
好奇怪啊。
是不是CSDN的数据库出问题了??我看了“我得分的贴子”没有什么变化啊??大家知道是怎么回事啊?