vb.net调试和理解一些公共的Function和MSDN的类

 

Module Module1
    Private Function StringToBoolean(ByVal parNum As String) As Boolean
        If parNum.Equals("0") Then
            Return False
        Else
            Return True
        End If
    End Function

    Sub Main()
        Dim r As Double

        Console.WriteLine(StringToBoolean(0).ToString)
        Console.WriteLine("按Enter退出")
        Console.ReadLine()
        End
    End Sub
End Module

 

'--------20111005-----------------------

Imports System
Imports System.IO

Module Module1

    Sub Main()
        Dim test1 As New Test
        test1.Main()

    End Sub


    Public Class Test
        Public Shared Sub Main()
            Dim path As String = "c:\temp\MyTest.txt"
            Dim sw As StreamWriter

            ' This text is added only once to the file.
            If File.Exists(path) = False Then
                ' Create a file to write to.
                sw = File.CreateText(path)

                sw.WriteLine("Hello")
                sw.WriteLine("And")
                sw.WriteLine("Welcome")
                sw.Flush()
                sw.Close()
            End If

            ' This text is always added, making the file longer over time
            ' if it is not deleted.
            sw = File.AppendText(path)
            sw.WriteLine("This")
            sw.WriteLine("is Extra")
            sw.WriteLine("Text")
            sw.Flush()
            sw.Close()

            ' Open the file to read from.
            Dim sr As StreamReader = File.OpenText(path)
            Dim s As String
            Do While sr.Peek() >= 0
                s = sr.ReadLine()
                Console.WriteLine(s)
            Loop
            sr.Close()
        End Sub
    End Class
End Module

 

 

-------20111116-----------------

Module Module1
    Private Function StringToBoolean() As String
        Dim sComboRouteChangeRule As String = "IN,INTS"
        Dim sMORoute As String = "AOINPOSN"
        Dim sTempNewMORoute As String = String.Empty
        Dim arrComboRules As String()
        Dim i, j As Integer
        Dim strComboRule As String()
        Dim strOldStage, strReplaceStages As String
        arrComboRules = sComboRouteChangeRule.Split(";")
        For i = 0 To arrComboRules.Length - 1

            If i > 0 Then
                sMORoute = sTempNewMORoute
            End If
            strComboRule = arrComboRules(i).Split(",")
            strOldStage = strComboRule(0)
            strReplaceStages = strComboRule(1)
            For j = 0 To sMORoute.Length - 1 Step 2
                If sMORoute.Substring(j, 2) = strOldStage Then
                    sTempNewMORoute = sMORoute.Replace(strOldStage, strReplaceStages)
                End If
            Next
        Next
        Return sTempNewMORoute
    End Function

    Sub Main()
        Dim r As Double

        Console.WriteLine(StringToBoolean().ToString)
        Console.WriteLine("按Enter退出")
        Console.ReadLine()
        End
    End Sub
End Module

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值