| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 414 人关注过本帖
标题:[求助]请看看我这个简单的程序问题出在哪?
只看楼主 加入收藏
waitrain
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2005-12-2
收藏
 问题点数:0 回复次数:3 
[求助]请看看我这个简单的程序问题出在哪?
我求一次小值,用vb编了个界面,但算出来结果不对,下面是我的程序,请帮忙看看,谢谢了!
Private Sub dminCommand_Click()
Dim a(14), T As Double
Dim I, J, N As Integer
a(0) = numberInput1(0).Text
a(1) = numberInput2(1).Text
a(2) = numberInput3(2).Text
a(3) = numberInput4(3).Text
a(4) = numberInput5(4).Text
a(5) = numberInput6(5).Text
a(6) = numberInput7(6).Text
a(7) = numberInput8(7).Text
a(8) = numberInput9(8).Text
a(9) = numberInput10(9).Text
a(10) = numberInput11(10).Text
a(11) = numberInput12(11).Text
a(12) = numberInput13(12).Text
a(13) = numberInput14(13).Text
a(14) = numberInput15(14).Text
N = number.Text
For J = 0 To N - 2
For I = 0 To N - J - 2
If a(I) > a(I + 1) Then
T = a(I)
a(I) = a(I + 1)
a(I + 1) = T
End If
Next I
Next J
For I = 0 To N - 1
Print a(I)
Next I
dminOutput.Text = a(1)
End Sub
但如果把a(0) = numberInput1(0).Text
a(1) = numberInput2(1).Text
a(2) = numberInput3(2).Text
a(3) = numberInput4(3).Text
a(4) = numberInput5(4).Text
a(5) = numberInput6(5).Text
a(6) = numberInput7(6).Text
a(7) = numberInput8(7).Text
a(8) = numberInput9(8).Text
a(9) = numberInput10(9).Text
a(10) = numberInput11(10).Text
a(11) = numberInput12(11).Text
a(12) = numberInput13(12).Text
a(13) = numberInput14(13).Text
a(14) = numberInput15(14).Text
它们改成a(0) = 548
a(1) =658
a(2) = 987
a(3) = 4645665
a(4) = 5485
a(5) = 785
a(6) = 1555
a(7) = 85
a(8) = 54
a(9) = 98
a(10) = 155
a(11) = 5855
a(12) = 1458
a(13) = 587
a(14) = 6454
就是直接改成数字就没问题,什么原因阿,谢谢
2006-11-06 15:04
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
a(0) =VAL(numberInput1(0).Text)
这样试试...........

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-11-06 15:13
waitrain
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2005-12-2
收藏
得分:0 
谢谢你啦,这回对啦,还有个小问题,如果我输入的数字,最小值有两个的话那么
dminOutput.Text = a(1) 不就成了最小值了吗?要是最小值有三个或更多怎么办?
有没有简单的判断方法

曾经沧海难为水 学习语言先学C !!!
2006-11-06 15:28
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 

使用循环 用&连接


[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-11-06 15:34
快速回复:[求助]请看看我这个简单的程序问题出在哪?
数据加载中...
 
   



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

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