تحويل التاريخ الي تكست

أولا يتم تحويل التاريخ الي مصفوفة

Private Function ConvertDateTimeToArray(dt As DateTime) As String()
 
       Return New List(Of String) From {dt.Year Mod 10000, dt.Month Mod 100, dt.Day Mod 100, dt.Hour Mod 100, dt.Minute Mod 100, dt.Second Mod 100}.ToArray

End Function

ثانيا نقوم تحويل المصفوفة الي تكست
 Private Function ConvertDateTimeToString(dt As DateTime) As String
        Dim result 
As String = ""
 
       For Each s As String In ConvertDateTimeToArray(dt)
 
           result += s
            result 
+= " "c
        Next
        Return result
.TrimEnd(" "c)End Function



 الإستخدام
Dim s As String = ConvertDateTimeToString(DateTime.Now)

Comments

Popular posts from this blog

مقدمة الي تشفير الحروف الأبجدية العربية

Add Custom Event to a Class in VB.NET

VB.NET Translucent Control using GDI+