01-11-25, 09:45 AM
السلام عليكم ورحمة الله و بركاته
كيف نعيد صياغة نص ليكون تاريخ مقبول
مثلا الصيغة التالية غير مقبولة:
22-09-25, 03:34 PM
اقصد برمجيا استقبلها ؟؟
وفقكم الله جميعا
13-09-12, 12:46 PMDim d = CDate("13-09-12, 12:46 PM")
Dim us_date = d.ToString(New CultureInfo("en-US"))
MsgBox(us_date)(01-11-25, 05:11 PM)Zuhare كتب : [ -> ]هل هذا المطلوب
كود :
Dim d = CDate("13-09-12, 12:46 PM")
Dim us_date = d.ToString(New CultureInfo("en-US"))
MsgBox(us_date)
Dim str As String = "^(\d{2})\-(\d{2})\-(\d{4})(,\s\d{2}:\d{2}\s[a-zA-Z]{2})$"
Dim reg As New Regex(str)
Dim ma As Match = reg.Match(TextBox1.Text)
Dim m, d, y, o As String
If ma.Success Then
d = ma.Groups(1).Value
m = ma.Groups(2).Value
y = ma.Groups(3).Value
o = ma.Groups(4).Value
Dim all As String = $"{m}-{d}-{y}{o}"
TextBox2.Text = (ToTimeStamp(all))
Else
MsgBox("false")
End IfDim d As DateTime = DateTime.ParseExact("13-09-12, 12:46 PM", "dd-MM-yy, hh:mm tt", CultureInfo.InvariantCulture)
Dim us_date = d.ToString(New CultureInfo("en-US"))
MsgBox(d & vbNewLine & us_date)(01-11-25, 05:39 PM)Zuhare كتب : [ -> ]هل التاريخ المدخل يبدا بالشهر ام باليوم وما الهدف اهو ان يبدا بالشهر ام باليوم؟
كود :
Dim d As DateTime = DateTime.ParseExact("13-09-12, 12:46 PM", "dd-MM-yy, hh:mm tt", CultureInfo.InvariantCulture)
Dim us_date = d.ToString(New CultureInfo("en-US"))
MsgBox(d & vbNewLine & us_date)
Dim d As DateTime = DateTime.ParseExact("13-09-12, 12:46 PM", "dd-MM-yy, hh:mm tt", CultureInfo.InvariantCulture)
MsgBox(d.Day)
MsgBox(d.Month)
MsgBox(d.Year)(01-11-25, 06:02 PM)Zuhare كتب : [ -> ]هذا المنتدى ينسق على يوم-شهر-سنه فيكفي هذا الكود ليعطيك التاريخ بنوع Date لتستطيع التعامل معه باخذ اليوم والشهر والسنه والساعه والدقيقه مثل
كود :
Dim d As DateTime = DateTime.ParseExact("13-09-12, 12:46 PM", "dd-MM-yy, hh:mm tt", CultureInfo.InvariantCulture)
MsgBox(d.Day)
MsgBox(d.Month)
MsgBox(d.Year)