There are alot of things which doesn't need to type alot of junk code while our task can be completed without declaring useless variables, constants, etc plus they use alot of resources when we run our executable so i decided to put some simple codes here which can achive our task easily

1-Description: Prevents than one instance of an application from running

'Place the following code in a Form_Load() or Sub Main()

If App.PrevInstance = True Then
Unload Me

2-'Description: Unloads an application properly ensuring restoration of resources

'Place the following code in a Form_Unload()

Dim i as integer
While forms.Count > 1
    ' Find first form besides "me" to unload
    i = 0

    While forms(i).Caption = Me.Caption
         i = i + 1

    Unload forms(i)

' Last thing to be done...
Unload Me

3- Description: Function returns True if date falls on a weekend

'Public Function IsWeekend(ByVal vntDate As Variant) As Boolean
     Dim bResult         As Boolean
     If IsDate(vntDate) Then
       If (WeekDay(vntDate) Mod 6 = 1) Then bResult = True Else bResult = False
       Err.Raise 13, "Type Mismatch, Must Be Date"
     End If
     IsWeekend = bResult
 'End Function

4- Description: Function returns True if year is a leap year

'Function IsLeapYear(ByVal sYear As String) As Boolean
 	If IsDate("02/29/" & sYear) Then
        	IsLeapYear = True
        	IsLeapYear = False
	End If
'End Function

5- 'Description: Detects if a file exists.

'Function FileExists (filename As String) As Integer
	On Error Resume Next
        x% = Len(Dir$(filename))
	If Err Or x% = 0 Then FileExists = False Else FileExists = True
'End Function

6- Description: Determines screen resolution

CR$ = Chr$(13) + Chr$(10)
TWidth% = screen.Width \ screen.TwipsPerPixelX
THeight% = screen.Height \ screen.TwipsPerPixelY
MsgBox "Screen Resolution:" + CR$ + CR$ + Str$(TWidth%) + " x" + Str$(THeight%), 64, "Info"

7- 'Description:Hide Mouse & Show Mouse
 'put this in your module

Declare Function ShowCursor& Lib "user32" _
    (ByVal bShow As Long)
    'Add this code to Command1.

Private Sub Command1_Click()
    ShowCursor (bShow = True)
End Sub
'Add this to Command2.

Private Sub Command2_Click()
    ShowCursor (bShow = False)
End Sub

8- Description: Opens / Closes the CD drive door without OCX 

'Private Declare Function mciSendString Lib "winmm.dll" Alias_ 
 "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
 ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

'Open CD drive door
retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0)

'Close CD drive door
retvalue = mciSendString("set CDAudio door closed", returnstring, 127, 0)

9- Description: Hide Application from Task Manager

can you pls help me how to make a vb program that will input keyboar character and then will output the reverse you enter....

Can you pls give me some vb codes on how can I put all the video clips in one frame (just like selections) and the code to open the link form...

Hi to everyone,

I am new in vb and just allow me to ask some questions.

I am working on a vb project that is manipulating data in AccessDB. I have been able to connect the Access DB ADODB.connection but I have not been able to display my Access tables on the Vb form.

Kindly assist.
Here is the code:
Sub DisplayIngredients()

Dim currentrow As Integer
Dim cndairycow As New ADODB.Connection
Dim rsNutRqmts As New ADODB.Recordset

With cndairycow
.ConnectionString = App.Path & "\dairycow.mdb"
.Provider = "Microsoft.Jet.Oledb.4.0"
End With

With rsNutRqmts
.ActiveConnection = cndairycow
.CursorType = adOpenKeyset
.Open "tb_ingredients"
End With
If rsNutRqmts.RecordCount > 0 Then
End If

currentrow = 1

Do While rsNutRqmts.EOF = False
With grdNutRqmts
.Rows = currentrow + 1
.Cols = 17
.Row = currentrow
.col = 1
.Text = rsNutRqmts!IngredientID
.col = 2
.Text = rsNutRqmts!IngredientName
.col = 3
.Text = rsNutRqmts!UnitPrice
.col = 4
.Text = rsNutRqmts!TDN
.col = 5
.Text = rsNutRqmts!CP
.col = 6
.Text = rsNutRqmts!RUP
.col = 7
.Text = rsNutRqmts!RDP
.col = 8
.Text = rsNutRqmts!CF
.col = 9
.Text = rsNutRqmts!ADF
.col = 10
.Text = rsNutRqmts!NDF
.col = 11
.Text = rsNutRqmts!Ca
.col = 12
.Text = rsNutRqmts!P
.col = 13
.Text = rsNutRqmts!A
.col = 14
.Text = rsNutRqmts!D
.col = 15
.Text = rsNutRqmts!Min
.col = 16
.Text = rsNutRqmts!Max


currentrow = currentrow + 1

End With
End Sub
the error message is="grdntrqments not defined?????

im a fresh mca student
these days started to work on one project on VB 2005
so need help in designing on problem statement...

Odin ID BSE NSE F&O Commodities Currency
Franchisee ID Consolidated
SYS702- Praveen r a a r r
SSS042-Sheetal r a r r r
SYS329-Sheetal r a a r r
SYS384- Ghanshyam a r r r r
SSS043- Ghanshyam r a r r r
SYS380- Prasad r r r a r

now if we click on any code id
it must show the next form which includes following:
Intra Day Delivery Futures Options Commodities Currency Total Brokerge Details Cash (MKT) Our share F&O (MKT) Our Share Ledger Extracts (In lacs)
Nos. Of clients Intraday Delivery Futures Options Commodities Currency In Cr. Cash In Cr. F&O B'rage BA share Cash F&O Commodities Currency Ageing > 5 Days Risk Limit Release

please help me
anyone who is intersted to join me as im planning to start my own software development company...prefering pune persons..
contact id : <<mail removed>>

I am creating birth alert project on vb(backend - access) so,
I want a vb code for display the birth dates from now date to 10 days
display this data on msflexgrid plz, help me

please send me which code would be the forms of the program would be closed and I will promis you ti send you favour

I have no idea why every post here is resurrecting an old thread with completely off topic questions, but it won't happen again...

commented: Hell Yeah!!!!! +19