如何在程序中正确使用For Next
循环。是否必须有For Next
循环的计数器。例如num = 1 to 1000
或者我可以让用户输入计数器的任何数字。
Module Module1
Sub Main()
Dim sq As Integer
For num As Integer = num >=
Console.WriteLine("Please enter a number")
num = Console.Read()
sq = num * num
Console.WriteLine("the square root is " & sq)
Next
End Sub
End Module
答案 0 :(得分:0)
这里是如何制作Sqrt功能并成功使用它,不需要使用for循环来做你想做的事情
Function Sqrt(x)As Integer
Dim root As Integer
root = x
root = root ^ (1 / 2)
Sqrt = root
End Function
Private Sub Command1_Click()
Num = InputBox("Please enter a number")
Print "The square root of " & Num & " is " & Sqrt(Num)
End Sub