我正在尝试将c#项目转换为vb.net项目。但是我不能在vb.net中转换一些代码。
C#代码:
if ((a >= 33) && (a <= 48)) { word += "|"; word1 += "|"; }Vb.net代码:
If (Char.GetNumericValue(a) >= 33) AndAlso (Char.GetNumericValue(a) <= 48) Then
word += "|"
word1 += "|"
End If在c#中,a的数值直接与整数值进行比较。但在Vb.net中,我无法获得a的数值来与ASCII值进行比较。是否有可能将c#项目解决方案转换为vb.net解决方案?让我知道解决方案。提前谢谢。
发布于 2018-04-09 15:11:07
您可以将字符值转换为其ASC值,然后将其与vb.net find示例代码中的值进行比较,如下所示
Dim a As Char
a = "a"
Dim i As Integer = Asc(a)
Console.Write(i.ToString())
If i < 90 Then
'Do what you want
End If发布于 2018-04-09 22:41:49
你应该使用VB的'AscW‘函数(而不是'Asc'),假设'a’是一个字符:
If (AscW(a) >= 33) AndAlso (AscW(a) <= 48) Then
word &= "|"
word1 &= "|"
End Ifhttps://stackoverflow.com/questions/49726757
复制相似问题