วันสุดท้ายของเดือน
Public Function GetLastDayOfMonth(ByVal CurrentDate As Date) As Date
Dim firstDay As New Date(CurrentDate.Year,
CurrentDate.Month, 1)
Dim result As Date =
firstDay.AddMonths(1).AddDays(-1)
Return result
End Function
|
บังคับใช้ ค.ศ. ในโปรแกรม
Sub New()
Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
End Sub
|
LINQ to SQL Timeout
dbc.CommandTimeout = 30 ' Default 30 Second
dbc.CommandTimeout = 60 ' Custom 60 Seconddbc.CommandTimeout = 0 ' Not Time Out
|
Empty List of Anonymous
Private Function CreateEmptyList(Of T)(ByVal unused As T) As List(Of T)
Return New List(Of T)()
End Function
Dim lstItemCredit = Me.CreateEmptyList(New With {.Item_ID = String.Empty, .Item_Name = String.Empty})
lstItemCredit.Add(New With {.Item_ID = "", .Item_Name = ""})
lstItemCredit.AddRange((From t0 In dbc.Item_Credits
Select New With {.Item_ID = t0.Item_ID.ToString, t0.Item_Name}).ToList)
|
อ่าน Text File ลงใน List of Object
Dim detailCsv = (From line In File.ReadAllLines(fullFileName)
Let forecastRecord = line.Split(",")
Skip (1)
Select New ForecastItem() With
{
.SiteID = forecastRecord(0),
.SiteName = forecastRecord(1),
.Day01 = forecastRecord(2),
.Day02 = forecastRecord(3),
.Day03 = forecastRecord(4),
.Day04 = forecastRecord(5),
.Day05 = forecastRecord(6),
…,
.Day25 = forecastRecord(26),
.Day26 = forecastRecord(27),
.Day27 = forecastRecord(28),
.Day28 = forecastRecord(29),
.Day29 = If(forecastRecord.Length > 30, forecastRecord(30), "0.00")
}).ToList()
|
Text Box เฉพาะตัวเลข
Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
Select Case e.KeyChar
Case "0" To "9"
If Me.TextBox1.Text.Length > 3 Then
e.Handled = Right(Me.TextBox1.Text, 3).Substring(0, 1) = "."
End If
Case "."
e.Handled = TextBox1.Text.Contains(".")
Case ControlChars.Back, Convert.ToChar(127)
e.Handled = False
Case Else
e.Handled = True
End Select
End Sub
|
แปลงวันที่ จาก String ระบุรูปแบบ
Dim strDate As String = "01 23 2013"
Dim output As DateTime = DateTime.ParseExact(strDate, "MM dd yyyy", Globalization.CultureInfo.InvariantCulture)
|
แปลง ตัวเลข เป็นรูปแบบ String
Dim input As Integer = 7 Dim output As String = input.ToString("0000#") |
แปลง ตัวเลข เป็นรูปแบบ , และทศนิยม 2 ตำแหน่ง
Me.txtDiffAmount.Text = String.Format("{0:n2}", intDiffAmount)
|
ไม่มีความคิดเห็น:
แสดงความคิดเห็น