Visual studio中 Console.WriteLine() 不显示解决办法 和 VB.NET字符串
1. 参考文档
2. 注意事项
务必将 Console.WriteLine() 改为 Debug.WriteLine(),并在即时窗口中查看
3. 字符串相关
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fname, lname, fullname, greeting As String
fname = "Rowan"
lname = "Atkinson"
fullname = fname + " " + lname
Debug.WriteLine("Full Name:{0}", fullname)
'by using string constructot
Dim letters As Char() = {"H", "e", "l", "l", "e"}
greeting = New String(letters)
Debug.WriteLine("Greetings:{0}", greeting)
'字符串比较
Dim str1, str2 As String
str1 = "This is test"
str2 = "This is text"
If (String.Compare(str1, str2) = 0) Then
Debug.WriteLine(str1 + " and " + str2 + " are equal.")
Else
Debug.WriteLine(str1 + " and " + str2 + " are not equal.")
End If
'字符串包含
'获取的子字符串
'字符串合并
'字符串复制
'字符串大小写转换
'删除字符串所有前导和尾部空格字符
End Sub
4. VB.Net - 函数
VB.Net有两种类型的程序:
- Functions
- Sub procedures or Subs
函数返回一个值,而Subs不返回值
4.1函数示例:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
a = findMax(2, 5)
Debug.WriteLine(a)
MsgBox(a)
End Sub
Function findMax(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Dim result As Integer
If (num1 > num2) Then
result = num1
Else
result = num2
End If
findMax = result
End Function