我正在尝试删除前导零/“0”来设置飞机的航向和俯仰,但我该怎么做呢?在最初的几次尝试中,我使用该CInt
函数将整数值转换为字符串值并将其转换回整数,但这只会出现错误。有人可以帮忙吗?提前致谢。
Dim pitchint As Integer
pitchint = Pitch_txt.Text
If pitchint > 720 Then
pitchint = pitchint - 720
Pitch_txt.Text = pitchint
Else
If pitchint > 360 Then
pitchint = pitchint - 360
Pitch_txt.Text = pitchint
End If
End If
If Pitch_txt.Text.Length <> 0 Then
If Pitchlbl.Text <> Pitch_txt.Text Then
Pitchlbl.Text = Pitch_txt.Text
End If
End If
以下是如果我想将 pitchint 放入字符串然后返回整数我会做的事情
Dim pitchint As String
pitchint = Pitch_txt.Text
pitchint = CInt(pitchint.TrimStart("0"))
If pitchint > 720 Then
pitchint = pitchint - 720
Pitch_txt.Text = pitchint
Else
If pitchint > 360 Then
pitchint = pitchint - 360
Pitch_txt.Text = pitchint
End If
End If
If Pitch_txt.Text.Length <> 0 Then
If Pitchlbl.Text <> Pitch_txt.Text Then
Pitchlbl.Text = Pitch_txt.Text
End If
End If
除了文本框和标签中返回的值相同之外,没有其他错误,即如果我输入 070,则返回的值是 070 没有变化。