如何在循环中保存该值(用于)?

编程入门 行业动态 更新时间:2024-10-12 03:26:57
本文介绍了如何在循环中保存该值(用于)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

从其他变量获取值时出现问题.绝对是不同的变量,但显示相同的值. 这是我的代码

I have a problem when get a value from different variable. It''s definitely different variable but it shown a same value. This my code

for k =1 to 10 If RC <= 10 Then ortu1 = k JumPar += 1 If JumPar = 2 Then ortu2 = k end if end if next

当我从ortu1和ortu2打印值时,它们显示相同的值. 我应该怎么办?我想获取第一个"k"值和第二个"k"值并将其设置在ortu1和ortu2中. 感谢您的帮助

When I print value from ortu1 and ortu2, they show a same value. What should I do? I want to get first ''k'' value and second ''k'' value and set it in ortu1 and ortu2. Thanks for help

推荐答案

问题是,每次循环时,您都将ortu1设置为k的值-然后检查是否还应该设置ortu2到k的值. 如果要在一个变量中使用第一个值,而在另一个变量中使用第二个值,则需要对它们都进行测试: The problem is that every time you go round the loop, you set ortu1 to the value of k - and then check if you should also set the value of ortu2 to k. If you want the first value in one variable and the second in another, then you will need to test them both: JumPar = 1; For k = 1 to 10 If RC <= 10 Then If JumPar = 1 Then ortu1 = k; Else If JumPar = 2 Then ortu2 = k; End If JumPar += 1; End If Next

更多推荐

如何在循环中保存该值(用于)?

本文发布于:2023-10-28 00:05:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534924.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!