This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'# 限制不可勾選項目 | |
'# when 某欄位值 = “不準勾選我” then 取消勾選。 | |
Private Sub lsvData_ItemCheck(ByVal itm As MSComctlLib.ListItem) | |
Debug.Print "ON : lsvData_ItemCheck → Index " & itm.Index & "," & itm.Text & "," & itm.Checked ' tracing | |
If itm.Checked = True Then '# 若勾選項目 | |
' parse fields | |
Dim FILE_NO, IMP_RETURN_DATE, IMP_REVERSAL_DATE As String | |
FILE_NO = itm.Text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' # | |
' # 依值設定ComboBox.ListIndex | |
' # VB6的Combox的操作實在不人性,只好讓它人性一些些。 | |
' # ref → http://stackoverflow.com/questions/18422210/vb6-select-combobox-text-value-based-on-database-data | |
' # 假設combox的list放資料的格式為:<value>.<dispaly_name> | |
' # eg. "0001.我是一號", "0002.我是二號二號", "0003.我是三號三號三號" | |
' # code → CombobBox_SetListIndexWithValue myCombox, "0002" | |
' # | |
Public Sub CombobBox_SetListIndexWithValue(cboData As ComboBox, value As String, Optional intCboLen As Integer = 4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Can I have an optional OUTPUT parameter in a stored procedure? | |
-- ref → http://stackoverflow.com/questions/3267523/can-i-have-an-optional-output-parameter-in-a-stored-procedure | |
-- Both input and output parameters can be assigned defaults. In this example: | |
CREATE PROCEDURE MyTest | |
@Data1 int | |
,@Data2 int = 0 | |
,@Data3 int = null output | |
AS | |
BEGIN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--# T-SQL同時使用TRY-CATCH與TRANSACTION語法 | |
--# ref → https://msdn.microsoft.com/zh-tw/library/ms175976(v=sql.120).aspx | |
BEGIN TRANSACTION; | |
BEGIN TRY | |
-- Generate a constraint violation error. | |
DELETE FROM Production.Product | |
WHERE ProductID = 980; | |
--IF @@TRANCOUNT > 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ============================================= | |
-- 在OpenQuery中使用參數 | |
-- 適用於讀取遠端資料庫時有join狀況下可加速查詢速度。 | |
-- ref → http://www.cnblogs.com/Dannier/archive/2011/09/21/openquery.html | |
-- ============================================= | |
CREATE PROCEDURE [dbo].[qryRemoteDatabase] | |
( | |
@CARD_NO VARCHAR(16) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# 繪圖閃爍 - 使用雙緩衝圖形解決 | |
// http://xyz.cinc.biz/2013/04/c.html | |
// http://msdn.microsoft.com/zh-tw/library/3t7htc9c.aspx | |
public Form1() | |
{ | |
InitializeComponent(); | |
this.DoubleBuffered = true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'# 取得DataGrid資料筆數 | |
Dim data_grid_row_count AS Long | |
data_grid_row_count = DataGrid.ApproxCount | |
'# 取 type name | |
Debug.Print TypeName(grdGroup.ApproxCount) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub CreateColumnsWithRS(ByRef list_view As ListView, ByRef rs As ADODB.Recordset) | |
Rem 依 Recordset 重建 ListView 欄位 | |
'# 清除現有欄位 | |
list_view.ColumnHeaders.Clear | |
'# 重新加入所有欄位 | |
Dim c As Field | |
For Each c In rs.fields | |
Debug.Print c.Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' | |
' 是否字串為英數字 | |
' | |
Public Declare Function IsCharAlphaNumeric Lib "user32" Alias "IsCharAlphaNumericA" (ByVal cChar As Integer) As Boolean | |
Public Function IsAlphaNumeric(astr As String) As Boolean | |
Dim i, n As Integer | |
n = Len(astr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function MakeDirectory(ByVal base_dir As String, ByVal dir_name As String) As String | |
Rem 建立目錄,若已建立就不再建立 | |
Rem 但一次只能建立1層目錄 | |
Dim full_dir_path As String | |
full_dir_path = base_dir & "\" & dir_name | |
If Dir(full_dir_path, vbDirectory) = "" Then ' 輸出目錄不存在,自動建立新的 | |
MkDir (full_dir_path) | |
End If |