当前位置:编程学习 > VB >>

我是VB新手,告诉该怎么办吧,谢谢

For i = 1 To 100 Step 1 If Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text) >= 0 Then Exit For Next i Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text) Label42(10).Caption = i * c Label42(10 + 11 - d).Caption = i * c End If 想实现的功能:c是个正整数,如果 Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text) >= 0 那么退出循环,如果此时i=5的话,那么i在接下来的运算也是5 如果Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text) <0 那么继续循环直到>=0 我现在这个运行了后 i*c显示出20(c=20),所以i=1,但实际Val(Label38.Caption) - Val(Text5(10).Text)肯定会让循环进行,所以i不应该是1,谁帮我改改,谢谢,我分有的是,如果对了,追加悬赏不是问题。我Q451317147,也可以QQ聊
答案:For i = 1 To 100  Step 1
 Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text)
    If val(Label40.Caption) >= 0 Then Exit For
    
Next i
其他:For i = 1 To 100 Step 1
    If  i * c + Val(Label38.Caption) - Val(Text5(10).Text)  >= 0 Then Exit For
   End If
Next i
Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text)
Label42(10).Caption = i * c
Label42(10 + 11 - d).Caption = i * c for循环内有问题吧?
If Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text) >= 0 Then Exit For
有这种写法?
是不是应该这样写:
For i = 1 To 100 Step 1
    If  i * c + Val(Label38.Caption) - Val(Text5(10).Text) >= 0 Then Exit For '选叛断条件,如果
                                  '大于则退出
Next i
Label40.Caption = i * c + Val(Label38.Caption) - Val(Text5(10).Text)   '赋值
Label42(10).Caption = i * c
Label42(10 + 11 - d).Caption = i * c 

上一个:怎么用vb在excel中上传图片 Dialog控件 commdlg.dll 高分悬赏~
下一个:VB 代码 问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,