Note2024072501_VisualStudio打印问题

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值