How to create a Autogenerated ID Number

Hello guys,this is sample code on how you to generate a Auto-Generated ID Number or a
Primary Key, because many programmers like me are want the ID Number or Primary Key
become Dynamic, so we can do the basic solution like this:

In my case i put it on a Sub Procedure that i placed it on a Module,so the this is the Code:

Sub EmployeePosition_ID()
Set rs=New Adodb.Recordset
    If rs.State = adStateOpen Then rs.Close
        rs.Open "SELECT MAX (right(Position_ID,6)) _
            from EmployeePositions", Conn
        If rs.EOF <> True Then
           Employee_Positions.txtID.Text = "SPC"  + "-"
         + Right("000000" _
            & IIf(IsNull(rs.Fields(0)), 1, rs.Fields(0) + 1), 6)
        End If
End Sub

How does it Works??

Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

How to Add Day in Date in Vb6

Hello guys,this time i will show to you, the use of  DateAdd Function, this function will use
for adding day(s) to a given date, for example i want to add 5 days on this given date  
"2/7/2011",so obviously we want the answer become "2/12/2011", to get this answer,just
simply follow this code:

DateAdd("d", 5, "2/7/2011")

since i am dealing with day(s) to add, this will represent with "d" if you want to add a
month(s), just replace "d" with "m" so its simple as counting 123.......

Happy Coding ^_^
The Hardest thing to do is to do Nothing ^_^
Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

How to Subtract Minutes in Vb6

Here is the basic way on how to subtract the minutes elapsed on the given time.

for example i have a time 12:00 PM and 1:00 PM so we can solved the elapsed time by
using  DateDiff function, so supposedly the answer is 60 mins. so enough words, the code
will look like this:

DateDiff("n", "12:00 PM", "1:00 PM")

the "n" there is represent the minutes value its similar on how to get the day elapsed that
represents by "d":

Note: if you doing this procedure you must place your subtrahend first or the lesser value,
otherwise you got a negative answer.

Happy Coding ^_^
The Hardest thing to do is to do Nothing ^_^
Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

How to retrieve the day,month,year,Weeks ,Hour,Minutes,Seconds passed in Vb6

this is the very basic way on how to use the DATEPART function in vb6,to retrieve
the day,month,year passed to the current date:

CODE:

Print "Days: " & DatePart("d", Now)
Print "Year: " & DatePart("yyyy", Now)
Print "Month: " & DatePart("m", Now)
Print "Quarter: " & DatePart("q", Now)
Print "Weeks: " & DatePart("w", Now)
Print "Hour: " & DatePart("h", Now)
Print "Minutes: " & DatePart("n", Now)
Print "Seconds: " & DatePart("s", Now)

Output:
the output will depends in your current system date,for my case,since my syte my
system date is December 21,2010 19:52:44 PM the output will look like this:

Days: 21
Year: 2010
Month: 12
Quarter: 4
Weeks: 3
Hour: 19
Minutes: 52
Seconds: 44

The Hardest Thing to Do is to Do Nothing
Hope you Like it Happy Coding!!!!
Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

How to Replace String in VB6

This sample code will show you on how to Replace a string on a Text-box Control using the  
Replace Function and the code will done like this:

Add  1 Text-box Control and 1 Command Button at the Text-box,Text property Put a Letter
A and put this code under the Command Button Click Event

Text1.Text = Replace(Text1.Text, "A", "B")

'this will Replace the letter A on the Text-box Control with Letter B, Hope you get the Logic!!!

The Hardest Thing to Do is to Do Nothing
Happy Coding (^_^)
Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

How to Filter the Special Characters in Vb6

This sample line of codes will show you on how to filter all
the special character on your keyboard that will inputted by
the user, this is very important to avoid the typo error, so we
want to trap it via this code

If KeyAscii >= 1 And KeyAscii <= 7 Or _

       KeyAscii >= 9 And KeyAscii <= 47 Or _

       KeyAscii >= 58 And KeyAscii <= 64 Or _

       KeyAscii >= 91 And KeyAscii <= 96 Or _

       KeyAscii >= 123 And KeyAscii <= 255 Then

            KeyAscii = 0

    End If

By determining the equivalent value of each character
you can browse your ASCII code,on the code given
i will not include the 65 to 90 because this range are holds
the value of A-Z and 48-57 that holds the range 0-9.
Hope this will help
Good Luck (^_^)
Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

How to Calculate Date using Date Diff and Date Add Function

this code will show you on how to calculate the difference of  two dates like for example 1
0/10/2010 to 10/01/2010 to find the lapsed day we use a Date Diff function that is 
built in VB6 so the code will look like this:

Label1.Caption = DateDiff("d", #10/1/2010#, #10/10/2010#)

at this code i display the output on a label control did you notice that the Date Diff function i
s there,since i am looking for  day lapsed to 10/01/2010 to 10/10/2010 the output is 9 if you 
are looking for a month just simply change the letter "d" to letter  "m" for a month symbol
and of  course it is not complete if i did  not include for a year,so for the year calculation just
simply change  also the letter on a two double quote(" ") to a "yyyy" and you  got the answer......

for a Month:
DateDiff("m", #10/1/2010#, #10/10/2010#)

 for a Year:
DateDiff("yyyy", #10/1/2010#, #10/10/2010#)

For the Date Add function for example we have add 3 days on the current date so it will
done like this:

this will add 3 days on your current system date 
 DateAdd("d", 3, Now)

this will add 3 months on your current system date
for a Month:
DateAdd("m", 3, Now)

 this will add 3 years on your current system date for a Year:
DateAdd("yyyy", 3, Now)

 Hope this will help to you!!
Happy Coding
Continue Reading with Borgy's Blog »
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

Copyright @ Codes-47.Blogspot.Com. Powered by Blogger.