| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 567 人关注过本帖
标题:新手,帮俺看看这段代码怎么错了??
只看楼主 加入收藏
oh123456
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2005-10-6
收藏
 问题点数:0 回复次数:4 
新手,帮俺看看这段代码怎么错了??

Private Sub Form_Load()
Public Sub procmin(a() As Integer)
Dim min As Integer
min = a(LBound(a))
For i = LBound(a) To UBound(a)
If a(i) < min Then
min = a(i)
End If
Next i
procmin = min
End Sub
Dim b(10) As Integer, t As Integer
For i = 0 To 9
b(i) = Int(Rnd * 101 + 300)
Next i
t = procmin(b())
Print t

End Sub

搜索更多相关主题的帖子: Sub 代码 Integer min 
2005-11-13 11:51
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 

很明显的错误,过程内不能声明过程。应该是:

Public Sub procmin(a() As Integer)
Dim min As Integer
min = a(LBound(a))
For i = LBound(a) To UBound(a)
If a(i) < min Then
min = a(i)
End If
Next i
procmin = min
End Sub

Private Sub Form_Load()
Dim b(10) As Integer, t As Integer
For i = 0 To 9
b(i) = Int(Rnd * 101 + 300)
Next i
t = procmin(b())
Print t

End Sub

2005-11-13 11:54
slore
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1108
专家分:0
注 册:2005-7-1
收藏
得分:0 
而且你的少了Randomize
所以是固定的哦~就不是随机了,

快上课了……
2005-11-13 11:59
oh123456
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2005-10-6
收藏
得分:0 
依旧编译不过“缺少函数或变量” ??

我一直在努力中……
2005-11-13 12:02
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 

唉,这是个函数啊,应该用 Function……

Public Function procmin(a() As Integer) As Integer
Dim min As Integer
min = a(LBound(a))
For i = LBound(a) To UBound(a)
If a(i) < min Then
min = a(i)
End If
Next i
procmin = min
End Function

Private Sub Form_Load()
Dim b(10) As Integer, t As Integer

Randomize
For i = 0 To 9
b(i) = Int(Rnd * 101 + 300)
Next i
t = procmin(b())
Print t

End Sub

[此贴子已经被作者于2005-11-13 12:19:13编辑过]

2005-11-13 12:16
快速回复:新手,帮俺看看这段代码怎么错了??
数据加载中...
 
   



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

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