且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将整数转换为任何字符串vb

更新时间:2023-01-16 17:45:24

读取它作为字符串,然后使用Integer.TryParse转换它:

  Dim  x  As  整数 
如果 整数 .TryParse(stringFromUser,x)然后
' 向用户报告问题。
返回
结束 如果跨度>


Hello, I've been spending most of the day trying to figure out how to properly convert from an integer to a string; so I can add a loop where if you input a letter instead of a number you have to re-enter.the number instead of just crashing. If anyone can point me in the right direction it would be much appreciated.

What I have tried:

Ive tried things along this line:

Score = Console.ReadLine() Or Score = CStr(Score)

Read it as a string, then use Integer.TryParse to convert it:
Dim x As Integer
If Not Integer.TryParse(stringFromUser, x) Then
	' report problem to user.
        Return
End If