在VB(Visual Basic)中,你可以使用多种方法来求取最大值。以下是一些常见的方法:
使用 `Math.Max` 方法
`Math.Max` 方法可以比较两个数值并返回其中的最大值。
```vb
Dim max As Double = Math.Max(10, 20)
Console.WriteLine(max) ' 输出 20
```
使用循环
如果你有一组数值,你可以通过循环来找到最大值。
```vb
Dim numbers() As Integer = {1, 3, 5, 7, 9