math function
文件大小: 7k
源码售价: 10 个金币 积分规则     积分充值
资源说明:Imports System.Globalization Imports System.Math Imports System.Collections.Generic Namespace xFunction Public Class f Const NumList = "零壹贰叁肆伍陆柒捌玖" Const UnitList = "仟佰拾亿仟佰拾万仟佰拾元角分" Public Shared Sub StringList() Dim tmepList As New List(Of String) Console.WriteLine(vbLf & "Capacity: {0}", tmepList.Capacity) tmepList.Add("Tyrannosaurus") tmepList.Add("Amargasaurus") tmepList.Add("Mamenchisaurus") tmepList.Add("Deinonychus") tmepList.Add("Compsognathus") Console.WriteLine() For Each dinosaur As String In tmepList Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "Capacity: {0}", tmepList.Capacity) Console.WriteLine("Count: {0}", tmepList.Count) Console.WriteLine(vbLf & "Contains(""Deinonychus""): {0}", _ tmepList.Contains("Deinonychus")) Console.WriteLine(vbLf & "Insert(2, ""Compsognathus"")") tmepList.Insert(2, "Compsognathus") Console.WriteLine() For Each dinosaur As String In tmepList Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "tmepList(3): {0}", tmepList(3)) Console.WriteLine(vbLf & "Remove(""Compsognathus"")") tmepList.Remove("Compsognathus") Console.WriteLine() For Each dinosaur As String In tmepList Console.WriteLine(dinosaur) Next tmepList.TrimExcess() Console.WriteLine(vbLf & "TrimExcess()") Console.WriteLine("Capacity: {0}", tmepList.Capacity) Console.WriteLine("Count: {0}", tmepList.Count) tmepList.Clear() Console.WriteLine(vbLf & "Clear()") Console.WriteLine("Capacity: {0}", tmepList.Capacity) Console.WriteLine("Count: {0}", tmepList.Count) End Sub #Region "RMB number to Word" Public Shared Function RmbNumberToWordFull(ByVal Number As Decimal) As String 'RMB 数字大写 If Number = 0 Then Return "零元整" If Number > 999999999999D Then Return "Error" Try Dim unitCharSet() As Char = UnitList.ToCharArray Dim digitalCharSet() As Char = NumList.ToCharArray Dim sOriginalNumber As String = CStr(Round(Number * 100, 0)) Dim cOriginalCharSet() As Char = sOriginalNumber.ToCharArray Dim numWords As String = "" Array.Reverse(cOriginalCharSet) Array.Reverse(unitCharSet) For i As Int16 = 0 To cOriginalCharSet.Length - 1 numWords = digitalCharSet(Val(cOriginalCharSet(i))) & unitCharSet(i) & numWords Next Return numWords Catch ex As Exception 'MessageBox.Show(ex.Message) Return "Error" End Try End Function Public Shared Function RmbNumberToWordStandard(ByVal Number As Decimal) As String Dim numWords As String = "" If Number = 0 Then Return "零元整" Try numWords = RmbNumberToWordFull(Number) For i As Int16 = 1 To 4 numWords = numWords.Replace("零仟", "零") numWords = numWords.Replace("零佰", "零") numWords = numWords.Replace("零拾", "零") numWords = numWords.Replace("零零", "零") numWords = numWords.Replace("零亿", "亿") numWords = numWords.Replace("零万", "万") numWords = numWords.Replace("零元", "元") numWords = numWords.Replace("亿万", "亿") numWords = numWords.Replace("零角零分", "整") numWords = numWords.Replace("零角", "零") numWords = numWords.Replace("零分", "整") Next Return numWords Catch ex As Exception Return "Error" End Try End Function #End Region End Class Public Class Collection(Of ItemType) Shared Items As New List(Of ItemType) Public Shared Sub Add(ByVal Value As ItemType) Items.Add(Value) End Sub Public Shared Function GetList() As ItemType End Function End Class Public Class xDatetime 'Dateteim convertion class,All functions are shared. Public Shared Function GetMonthList(Optional ByVal MonthCount As Int16 = 5) As String() If MonthCount = 0 Then MonthCount = 1 End If Dim ItemCount As UInt16 = Math.Abs(MonthCount) - 1 Dim dt As Date Dim Monthlist(ItemCount) As String dt = Date.Today For iMonth As Int16 = 0 To ItemCount Step 1 Dim newDT As Date If MonthCount >= 0 Then newDT = DateAdd(DateInterval.Month, iMonth, dt) Else newDT = DateAdd(DateInterval.Month, iMonth + MonthCount, dt) End If Monthlist(iMonth) = newDT.ToString("yyyyMM") Next Return Monthlist End Function Public Shared Function CYYYYMMToMMM(ByVal RegionName As String, ByVal sYYYYMM As String) As String 'Convert month formatn egg .convert "201101" to "Jan" 'Note: string start position is begin form 0 Dim dt As DateTime = New DateTime(sYYYYMM.Substring(0, 4), sYYYYMM.Substring(4, 2), 1) Select Case RegionName Case "US" CYYYYMMToMMM = dt.ToString("MMM", DateTimeFormatInfo.InvariantInfo) Case "CN" CYYYYMMToMMM = dt.ToString("MMM", DateTimeFormatInfo.InvariantInfo) Case Else CYYYYMMToMMM = dt.ToString("MMM", DateTimeFormatInfo.InvariantInfo) End Select End Function Public Shared Function MonthFirstDayYYYYMMDD(ByVal sYYYYMM As String) As String Dim dt As DateTime = New DateTime(sYYYYMM.Substring(0, 4), sYYYYMM.Substring(4, 2), 1) Return dt.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo) End Function Public Shared Function MonthLastDayYYYYMMDD(ByVal sYYYYMM As String) As String Dim dt As DateTime = New DateTime(sYYYYMM.Substring(0, 4), sYYYYMM.Substring(4, 2), 1) dt = dt.AddMonths(1).AddDays(-1) Return dt.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo) End Function End Class End Namespace
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。