在TEXTBOX 上顯示金額
'將金額格式化
Dim Amount as integer = 88971
TextBox1.Text = FormatCurrency(Amount, 0, TriState.True, TriState.False, TriState.True)
結果顯示 NT$88,971
'將金額格式化且不顯示貨幣符號
Dim Amount as integer = 88971
TextBox1.Text = FormatCurrency(Amount, 0, TriState.True, TriState.False, TriState.True).Replace("NT$", "")
結果顯示 88,971
參考連結:
Strings.FormatCurrency(Object, Int32, TriState, TriState, TriState) Method
2019年4月18日 星期四
2019年4月15日 星期一
[VB.NET] [SQL] 判斷字元是英文或是數字
[VB.NET]
Dim str As String = ""
str = TextBox1.Text
Dim str1 As String = str.Substring(0, 1)
Dim str2 As String = str.Substring(4, 1)
If IsNumeric(str1) = True And Char.IsLetter(str2) = True Then
MsgBox("第一個字是數字:" & str1 & " 第五字是英文:" & str2)
Else
MsgBox("OK 第一個字是數字:" & str1 & " 第五字是英文:" & str2)
End If
End If
[SQL]
' [0-9]% 找出開頭為數字的資料
' %[A-Z] 找出結尾為英文字母的資料
SELECT *
FROM TESTTABLE
WHERE (Column1 LIKE '[0-9]%') AND (Column1 LIKE '%[A-Z]')
參考:判斷身分證字號及統一編號是否正確
2019年4月10日 星期三
[GrapeCity][Spread Windows Forms] combine sheet to one PDF 實作合併sheet 匯出一個PDF檔案
'單一FPSpread
Public Sub CombinePDFFiles()
Dim printset As FarPoint.Win.Spread.PrintInfo = New FarPoint.Win.Spread.PrintInfo()
printset.PrintToPdf = True
printset.PdfWriteMode = PdfWriteMode.Append
printset.PdfFileName = "D:\TEST\testPDF_" & Format(Now, "yyyyMMddHHmmss") & ".pdf"
FpSpread1.Sheets(0).PrintInfo = printset
FpSpread1.Sheets(1).PrintInfo = printset
FpSpread1.Sheets(2).PrintInfo = printset
FpSpread1.PrintSheet(-1)
End Sub
原本希望將多個FPSpread 直接合併匯出一個PDF檔案,實測後是不支援的
所以比較好的做法是直接將兩個檔案合併到同一個FPSpread中
'多個FPSpread
Public Sub CombinePDFFiles()
Dim Spread As FarPoint.Win.Spread.FpSpread = New FarPoint.Win.Spread.FpSpread()
Spread.BringToFront()
Spread.Size = New System.Drawing.Size(600, 300)
Spread.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
Dim coll As FarPoint.Win.Spread.SheetViewCollection
coll = Spread.Sheets
coll.Add(FpSpread1.Sheets(0))
coll.Add(FpSpread2.Sheets(0))
Dim printset As FarPoint.Win.Spread.PrintInfo = New FarPoint.Win.Spread.PrintInfo()
printset.PrintToPdf = True
printset.PdfWriteMode = PdfWriteMode.Append
printset.PdfFileName = "D:\TEST\testPDF_" & Format(Now, "yyyyMMddHHmmss") & ".pdf"
Me.Controls.Add(Spread)
Spread.Sheets(0).PrintInfo = printset
Spread.Sheets(1).PrintInfo = printset
Spread.PrintSheet(-1)
End Sub
這方法也是可行,但我覺得如果設計成自動產生會造成元件的負擔
應該蠻容易crash的
程式碼
訂閱:
文章 (Atom)