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