"Declares": "Global Const WM_USER = &H400\r\nGlobal Const LB_SETHORIZONTALEXTENT = (WM_USER + 21)\r\nDeclare Function SendMessage Lib \"User\" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long\r\n\r\n",
"Code": "' set horizontal scroll bar for list box\r\nDim newwidth%\r\nDim tpp% ' Twips per Pixel\r\n\r\ntpp% = Screen.TwipsPerPixelX\r\nnewwidth% = (TextWidth(longest$ + \"WWWW\") / tpp%)\r\n\r\nlonger& = SendMessage(list1.hWnd, LB_SETHORIZONTALEXTENT, newwidth%, &H0)\r\n\r\n' end of set horizontal scroll bar for list box\r\n"
},
{
"Item": "List Box Tabs",
"Declares": "Global Const WM_USER = &H400\r\nGlobal Const LB_SETTABSTOPS = (WM_USER + 19)\r\nDeclare Function SendMessage Lib \"User\" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long\r\n\r\n",
"Code": "' set tab stops in list box - 4 dialog units/character\r\n' therefore, 24/4 = tab at character 6\r\nDim longer&\r\nReDim tabvals%(3)\r\n\r\ntabvals%(0) = 40\r\ntabvals%(1) = 80\r\ntabvals%(2) = 120\r\ntabvals%(3) = 160\r\n\r\nlonger& = SendMessage(list1.hWnd, LB_SETTABSTOPS, 4, tabvals%(0))\r\n\r\n' end of set tab stops"
},
{
"Item": "Common Dialog - File New",
"Code": "\r\nDim cd As Control\r\n\r\nSet cd = Me.CMDialog1\r\n\r\n'set cancel to true\r\ncd.CancelError = True\r\n\r\nOn Error GoTo File_New_Error\r\n\r\ncd.DialogTitle = \"New File\"\r\ncd.InitDir = app.Path\r\ncd.Filter = \"Text (*.TXT)|*.txt|Documents (*.DOC)|*.doc\"\r\ncd.Flags = OFN_PATHMUSTEXIST Or OFN_HIDEREADONLY Or OFN_CREATEPROMPT\r\ncd.Action = DLG_FILE_OPEN\r\n\r\nmsg$ = \"You selected file \" & cd.Filetitle & Chr$(10) & \" and it's full path is\" & Chr$(10) & cd.Filename & \".\"\r\ntitle$ = \"New File Selected\"\r\nMsgBox msg$, , title$\r\n\r\nExit Sub\r\n\r\nFile_New_Error:\r\nExit Sub\r\n"
},
{
"Item": "Common Dialog - File Open",
"Code": "Dim cd As Control\r\n\r\nSet cd = Me.CMDialog1\r\n\r\n'set cancel to true\r\ncd.CancelError = True\r\n\r\nOn Error GoTo File_Open_Error\r\n\r\ncd.DialogTitle = \"Open File\"\r\ncd.InitDir = app.Path\r\ncd.Filter = \"Text (*.TXT)|*.txt|Documents (*.DOC)|*.doc\"\r\ncd.Flags = OFN_PATHMUSTEXIST Or OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST\r\ncd.Action = DLG_FILE_OPEN\r\n\r\nmsg$ = \"You selected file \" & cd.Filetitle & Chr$(10) & \" and it's full path is\" & Chr$(10) & cd.Filename & \".\"\r\ntitle$ = \"Open File Selected\"\r\nMsgBox msg$, , title$\r\n\r\nExit Sub\r\n\r\nFile_Open_Error:\r\nExit Sub\r\n\r\n"
},
{
"Item": "Common Dialog - Print",
"Code": "Dim cd As Control\r\n\r\nSet cd = Me.CMDialog1\r\n\r\n'set cancel to true\r\ncd.CancelError = True\r\n\r\nOn Error GoTo File_Print_Error\r\n\r\ncd.DialogTitle = \"Print File\"\r\ncd.Copies = 1\r\ncd.FromPage = 1\r\ncd.ToPage = 2\r\ncd.Min = 1\r\ncd.Max = 2\r\ncd.Flags = PD_NOSELECTION\r\ncd.Action = DLG_PRINT\r\n\r\nmsg$ = \"You selected from page \" & cd.FromPage & \" to \" & cd.ToPage & \".\"\r\n\r\nIf (cd.Flags And PD_PRINTTOFILE) = PD_PRINTTOFILE Then\r\n msg$ = msg$ & Chr$(10) & Chr$(10) & \"You selected Print to File.\"\r\nElse\r\n msg$ = msg$ & Chr$(10) & Chr$(10) & \"You selected Print to Printer.\"\r\nEnd If\r\ntitle$ = \"Print File\"\r\nMsgBox msg$, , title$\r\n\r\nExit Sub\r\n\r\nFile_Print_Error:\r\nExit Sub\r\n\r\n"
},
{
"Item": "Common Dialog - Print Setup",
"Code": "Dim cd As Control\r\n\r\nSet cd = Me.CMDialog1\r\n\r\n'set cancel to true\r\ncd.CancelError = True\r\n\r\nOn Error GoTo File_PrintSetup_Error\r\n\r\ncd.Flags = PD_PRINTSETUP\r\ncd.Action = DLG_PRINT\r\n\r\nExit Sub\r\n\r\nFile_PrintSetup_Error:\r\nExit Sub\r\n"
"Code": "Dim cd As Control\r\n\r\nSet cd = Me.CMDialog1\r\n\r\n'set cancel to true\r\ncd.CancelError = True\r\n\r\nOn Error GoTo Fonts_Form_Error\r\n\r\ncd.DialogTitle = \"Form Font Selection\"\r\ncd.FontName = Me.FontName\r\ncd.FontSize = Me.FontSize\r\ncd.FontBold = Me.FontBold\r\ncd.FontItalic = Me.FontItalic\r\ncd.Flags = CF_SCREENFONTS Or CF_ANSIONLY Or CF_FORCEFONTEXIST\r\ncd.Action = DLG_FONT\r\n\r\nMe.FontName = cd.FontName\r\nMe.FontSize = cd.FontSize\r\nMe.FontBold = cd.FontBold\r\nMe.FontItalic = cd.FontItalic\r\nMe.Refresh\r\n\r\nCall Form_Paint\r\n\r\nExit Sub\r\n\r\nFonts_Form_Error:\r\nExit Sub\r\n"
},
{
"Item": "Common Dialog - Color",
"Code": "Dim cd As Control\r\n\r\nSet cd = Me.CMDialog1\r\n\r\n'set cancel to true\r\ncd.CancelError = True\r\n\r\nOn Error GoTo Form_BC_Error\r\n\r\ncd.DialogTitle = \"Form Back Color Selection\"\r\ncd.Color = Me.BackColor\r\ncd.Flags = CC_RGBINIT\r\ncd.Action = DLG_COLOR\r\n\r\nMe.BackColor = cd.Color\r\nMe.Refresh\r\n\r\nExit Sub\r\n\r\nForm_BC_Error:\r\nExit Sub\r\n"
},
{
"Item": "Text Box - Uppercase Only",
"Code": " If keyascii = 13 Then\r\n \r\n ' this line keeps the keyboard from beeping\r\n keyascii = 0\r\n\r\n ' this line cases the cursor to move to the next field\r\n SendKeys \"{TAB}\"\r\n\r\n Else\r\n \r\n ' to convert all entered data to uppercase we do the following\r\n ' 1. convert the ascii code to a character - Chr$(Keyascii)\r\n ' 2. convert the character to uppercase Ucase(Chr$(keyascii))\r\n ' 3. convert the uppcase Character back to ascii Asc(Ucase(Chr$(keyascii)))\r\n keyascii = Asc(UCase(Chr$(keyascii)))\r\n\r\n End If\r\n"
},
{
"Item": "Text Box - Numbers Only",
"Code": " ' this routine allows the processing of numbers only\r\n If keyascii = 13 Then\r\n keyascii = 0\r\n SendKeys \"{TAB}\"\r\n Else\r\n If keyascii >= 48 And keyascii <= 57 Then\r\n ' okay accept the number\r\n ElseIf keyascii = 8 Then\r\n ' let the backSpace key work\r\n Else\r\n ' not a number so lose the keystroke\r\n keyascii = 0\r\n End If\r\n End If\r\n"
},
{
"Item": "Form - Center",
"Code": "' center form\r\nLeft = (Screen.Width - Width) / 2 ' Center form horizontally.\r\nTop = (Screen.Height - Height) / 2 ' Center form vertically.\r\n"