Programming Tips

Set Default Page Setup in ReportViewer

Dim pg As New System.Drawing.Printing.PageSettings()     pg.Margins.Top = 0     pg.Margins.Bottom = 0.25                pg.Margins.Left = 0                pg.Margins.Right = 0 Dim size As System.Drawing.Printing.PaperSize = New PaperSize("custom", 300, 200) 'the custom size 3in x 2in     pg.PaperS…

Get Distinct Maximum Date

Get Distinct Maximum Date Display the latest order of each customers. SELECT A.CustomerID, OrderDate, EmployeeID, ShipperID FROM Orders AS A INNER JOIN (SELECT CustomerID, MAX(OrderDate) AS MaxOrderDate FROM Orders GROUP BY CustomerID) AS B ON A.CustomerID=B.CustomerID AND A.OrderDate=B.MaxOrderDate

VB.Net Message Box Modal

MsgBox("Modal Message", MsgBoxStyle.SystemModal + MsgBoxStyle.Exclamation, "VB.Net Message Box Modal")

How To Embed Windows Media Player In Windows Form Using VB.Net

How To Embed Windows Media Player In Windows Form Using VB.Net 1. Go to "Tool Box" pane  then right click 2. Select "Choose Items..." 3. Click "COM Components" tab 4. Select/Check the "Windows Media Player" component 5. Click OK 6. Drag the component "Windows Media P…

How To Get The Movie Duration Using VB.Net

Function Get Movie Duration(ByVal MovieFullPath As String) As String      If File.Exists(MovieFullPath) Then         Dim objShell As Object = CreateObject("Shell.Application")         Dim objFolder As Object = _            objShell.Namespace(Path.GetDirectoryName(MovieFullPath))    …

Calculate Total Hour and Minute in SQL

SELECT ((DATEDIFF(minute, '2013-06-30 08:30:00.0000000', '2013-06-30 10:45:00.0000000'))/60) AS TotalHour,        ((DATEDIFF(minute, '2013-06-30 08:30:00.0000000', '2013-07-30 10:45:00.0000000'))%60) AS TotalMinute The result of the above query is: TotalHour    TotalMinute       …

Get Windows User Full Name in VB 6

Code in getting the windows user's fullname. Dim strComputer As String Dim strUserName As String Dim objUser As Object strComputer = "ComputerName" strUserName = "UserName Set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName) msgbox objUser.Fu…

Multiple JOIN in MS Access

When you query a multiple join in MSSQL you use this following query: SELECT a.columna, b.columnb, c.columnc FROM tablea AS a LEFT JOIN tableb AS b ON a.id = b.id LEFT JOIN tablec AS c ON a.id = c.id If you use the above query in  MS Access you will encounter an error message "Missing Operator". To reso…

SQL Time Difference

Subtracting Date Time in MSSQL --YEAR SELECT DATEDIFF(year, '2012-12-31', '2013-01-01') --Quarter SELECT DATEDIFF(quarter, '2012-01-01 23:59:59', '2013-01-01 00:00:00') --Month SELECT DATEDIFF(month, '2012-12-31 23:59:59.9999999', '2013-02-01 00:00:00.0000000'…

VB 6 Send Email

VB Send Email with a HTML Format body Private Sub Command1_Click() Dim EmailList, Mailbod As String, Myfile Dim objOutlook As Outlook.Application Dim newapp As Outlook.MailItem, objRecip As Outlook.Recipient Dim objRWhtm As Outlook.Attachment Dim StrBody As String Dim Myfile As String StrBody="<font …

Copy file and rename copied file using MS DOS command

Copy File then rename the copied file with date and time using dos command C:\FileName.bak Z:\ /C /Y ren Z:\FileName.bak FileName.bak%date:~4,2%-%date:~7,2%-%date:~10,4%-%time:~1,1%%time:~3,2%%time:~6,2% I discovered that when the folder name is with spaces. just put a double qoute. XCOPY C:\FileName.bak Y:\"…

Disable/Enable MS Access Ribbon

When your developing an MS Access application make sure you remove the Ribbon so that your application looks clean. Here's how to remove the Ribbon. 'Disable MS Access Ribbon DoCmd.ShowToolbar "Ribbon", acToolbarNo 'Enable MS Access Ribbon DoCmd.ShowToolbar "Ribbon", acToolbar…

Load More
That is All