March 28, 2007

3

Fighting for the World's Smallest Website

Did you ever noticed that there is some webmasters are fighting for the title of World's Smallest Website? The first website I know doing this is guimp.com where it is only 18x18 pixels in size which is smaller than a small fingernail. But yet it have all the functionality to be voted as qualified website where it have site navigation, and even packed full of fun projects including pong, pacman, space invaders, pinball, a blog and pixel art.

Then I started googling around to find whether this is the one and only smallest website in the world but no... There is other websites with smaller size and have the equal functions too. You can check it out for yourself. The sites that I have found with this intention to be the Smallest Website are:

http://www.guimp.com - 18 x 18 pixels
http://dot16.pixeltemple.com - 16 x 16 pixels
http://www.coolornot.com/ - 15 x 17 pixels
http://www.121pixels.tk - 11 x 11 pixels

So, if you found something like this and I didn't list it here, please feel free to contact me and gimme the link so I can add it here.

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy




1

My Cheat Code to Create Properties in VB6

Did you ever feel lazy to type the same code with a small modification but it is every where. And doing the same work repeatedly for let say 34 times? I will feel like my hand got the RSI (Repetitive Strain Injury). The most common task that I encounter this situation is when creating a set of properties for any classes. As the time goes I discover a cheap cheat code to reduce my coding work and let some script do my repeated work for me...

Here is my code to create a set of 17 properties in a class...

Public Sub MakePropCode()
Dim vsProp
Dim vlProp
Dim vbProp
Dim i As Long
Dim sOutPut As String

' array of string properties
vsProp = Array("ISNFolder", "ISDFolder", "CSVFolder", _
"DBHost", "DBUser", "DBPassword", _
"RDBHost", "RDBUser", "RDBPassword", _
"LogPath", "DRSMHost", "DRSMID", "DRSMPassword")

' array of long properties
vlProp = Array("SeqInterval", "SeqType")

' array of boolean properties
vbProp = Array("WriteLog")

sOutPut = "Option Explicit" & vbCrLf & vbCrLf

' private declaration for string property
For i = 0 To UBound(vsProp)
sOutPut = sOutPut & "Private m_s" & vsProp(i) & _
" As String" & vbCrLf
Next

' private declaration for long property
For i = 0 To UBound(vlProp)
sOutPut = sOutPut & "Private m_l" & vlProp(i) & _
" As Long" & vbCrLf
Next

' private declaration for boolean property
For i = 0 To UBound(vbProp)
sOutPut = sOutPut & "Private m_b" & vbProp(i) & _
" As Boolean" & vbCrLf
Next

sOutPut = sOutPut & vbCrLf & vbCrLf

' public get & let declaration for string prop

For i = 0 To UBound(vsProp)
sOutPut = sOutPut & "Public Property Get " & vsProp(i) & _
"() As String" & vbCrLf
sOutPut = sOutPut & " " & vsProp(i) & " = m_s" & _
vsProp(i) & vbCrLf
sOutPut = sOutPut & "End Property" & vbCrLf & vbCrLf
sOutPut = sOutPut & "Public Property Let " & vsProp(i) & _
"(ByVal sNew As String)" & vbCrLf
sOutPut = sOutPut & " m_s" & vsProp(i) & " = sNew" & _
vbCrLf
sOutPut = sOutPut & "End Property" & vbCrLf & vbCrLf
Next

' public get & let declaration for long prop

For i = 0 To UBound(vlProp)
sOutPut = sOutPut & "Public Property Get " & vlProp(i) & _
"() As Long" & vbCrLf
sOutPut = sOutPut & " " & vlProp(i) & " = m_l" & _
vlProp(i) & vbCrLf
sOutPut = sOutPut & "End Property" & vbCrLf & vbCrLf
sOutPut = sOutPut & "Public Property Let " & vlProp(i) & _
"(ByVal lNew As Long)" & vbCrLf
sOutPut = sOutPut & " m_l" & vlProp(i) & " = lNew" & _
vbCrLf
sOutPut = sOutPut & "End Property" & vbCrLf & vbCrLf
Next

' public get & let declaration for boolean prop

For i = 0 To UBound(vbProp)
sOutPut = sOutPut & "Public Property Get " & vbProp(i) & _
"() As Boolean" & vbCrLf
sOutPut = sOutPut & " " & vbProp(i) & " = m_b" & _
vbProp(i) & vbCrLf
sOutPut = sOutPut & "End Property" & vbCrLf & vbCrLf
sOutPut = sOutPut & "Public Property Let " & vlProp(i) & _
"(ByVal bNew As Boolean)" & vbCrLf
sOutPut = sOutPut & " m_b" & vbProp(i) & " = bNew" & _
vbCrLf
sOutPut = sOutPut & "End Property" & vbCrLf & vbCrLf
Next

' write it to a text file in the same directory of the project
Open App.Path & "\prop.txt" For Output As #1
Print #1, sOutPut
Close #1

Debug.Print "Finished!"

End Sub

How to use it? The way that I'm using it is by creating one extra module in my project which I can delete later. Paste the code and modify the Property Names with their type array. then type the function name on the Immediate Window and press enter. Tadaaa!! My properties set of property get and property let is created in a text file called prop.txt

This is the text file output of this function:

Option Explicit

Private m_sISNFolder As String
Private
m_sISDFolder As String
Private
m_sCSVFolder As String
Private
m_sDBHost As String
Private
m_sDBUser As String
Private
m_sDBPassword As String
Private
m_sRDBHost As String
Private
m_sRDBUser As String
Private
m_sRDBPassword As String
Private
m_sLogPath As String
Private
m_sDRSMHost As String
Private
m_sDRSMID As String
Private
m_sDRSMPassword As String
Private
m_lSeqInterval As Long
Private
m_lSeqType As Long
Private
m_bWriteLog As Boolean


Public Property Get ISNFolder() As String
ISNFolder = m_sISNFolder
End Property

Public Property Let ISNFolder(ByVal sNew As String)
m_sISNFolder = sNew
End Property

Public Property Get ISDFolder() As String
ISDFolder = m_sISDFolder
End Property

Public Property Let ISDFolder(ByVal sNew As String)
m_sISDFolder = sNew
End Property

Public Property Get CSVFolder() As String
CSVFolder = m_sCSVFolder
End Property

Public Property Let CSVFolder(ByVal sNew As String)
m_sCSVFolder = sNew
End Property

Public Property Get DBHost() As String
DBHost = m_sDBHost
End Property

Public Property Let DBHost(ByVal sNew As String)
m_sDBHost = sNew
End Property

Public Property Get DBUser() As String
DBUser = m_sDBUser
End Property

Public Property Let DBUser(ByVal sNew As String)
m_sDBUser = sNew
End Property

Public Property Get DBPassword() As String
DBPassword = m_sDBPassword
End Property

Public Property Let DBPassword(ByVal sNew As String)
m_sDBPassword = sNew
End Property

Public Property Get RDBHost() As String
RDBHost = m_sRDBHost
End Property

Public Property Let RDBHost(ByVal sNew As String)
m_sRDBHost = sNew
End Property

Public Property Get RDBUser() As String
RDBUser = m_sRDBUser
End Property

Public Property Let RDBUser(ByVal sNew As String)
m_sRDBUser = sNew
End Property

Public Property Get RDBPassword() As String
RDBPassword = m_sRDBPassword
End Property

Public Property Let RDBPassword(ByVal sNew As String)
m_sRDBPassword = sNew
End Property

Public Property Get LogPath() As String
LogPath = m_sLogPath
End Property

Public Property Let LogPath(ByVal sNew As String)
m_sLogPath = sNew
End Property

Public Property Get DRSMHost() As String
DRSMHost = m_sDRSMHost
End Property

Public Property Let DRSMHost(ByVal sNew As String)
m_sDRSMHost = sNew
End Property

Public Property Get DRSMID() As String
DRSMID = m_sDRSMID
End Property

Public Property Let DRSMID(ByVal sNew As String)
m_sDRSMID = sNew
End Property

Public Property Get DRSMPassword() As String
DRSMPassword = m_sDRSMPassword
End Property

Public Property Let DRSMPassword(ByVal sNew As String)
m_sDRSMPassword = sNew
End Property

Public Property Get SeqInterval() As Long
SeqInterval = m_lSeqInterval
End Property

Public Property Let SeqInterval(ByVal lNew As Long)
m_lSeqInterval = lNew
End Property

Public Property Get SeqType() As Long
SeqType = m_lSeqType
End Property

Public Property Let SeqType(ByVal lNew As Long)
m_lSeqType = lNew
End Property

Public Property Get WriteLog() As Boolean
WriteLog = m_bWriteLog
End Property

Public Property Let SeqInterval(ByVal bNew As Boolean)
m_bWriteLog = bNew
End Property

Since I have this code, I don't have to code like this again and again. Simply copy and paste, then edit the appropriate line. Nasty cheat code right? You can freely use and distribute this code but please credit my name if you post it somewhere on the net and please link to this page too. Have Fun!

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

0

How to Flip Your Visual Basic Form in another Form

I recently joined myLot forum. It is a paid to post forum introduced by my friend. Hah! Hah! I'm thinking about making money while hanging around the net with friends. Isn't that great? You can get money if you start a good discussion and even get money when responding in discussion in a good manners. The good thing is myLot can pay me via PayPal or e-Gold. So, if you are interested too, then you can simply join the myLot forum for free by clicking here and then click on sign up.

Ups, back to the topic. While browsing the forum, I found a Visual Basic question about how to flip the content of the VB form. So, I decided to help him and make this simple step by step code.

OK lets make it simple because I also hate to type a lot . We are using VB6 to create this small project. So, make sure you have VB6 installed to follow this steps.

Step 1: Open up VB6 and create new project using 'Standard EXE'.

Step 2: Add one CommandButton (we will use this to trigger the flipping)

Step 3: Add other controls we like (e.g: labels, frame, image, picture), arrange and modify their property as we like.

Step 4: Add other form (the name by default is Form2... let it be like that)

Step 5: Add a PictureBox control in Form2.

Step 6: Paste This code in Form1

Option Explicit

Private Declare Function
StretchBlt Lib "gdi32" ( _
ByVal hDC As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal nSrcWidth As Long, _
ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Private Const
SRCCOPY = &HCC0020

Private Sub Command1_Click()
Dim lx As Long
Dim
ly As Long
Dim
lRet As Long

' get the size of Form1
lx = ScaleX(Me.ScaleWidth, Me.ScaleMode, vbPixels)
ly = ScaleY(Me.ScaleHeight, Me.ScaleMode, vbPixels)

' load Form2 but hide it
Call Form2.Hide

' resize the picture in Form2 to fit our Form1 size
Call Form2.Picture1.Move(0, 0, Me.ScaleWidth, Me.ScaleHeight)

' Set the AutoRedraw True to let it paint
Form2.Picture1.AutoRedraw = True

' use a simple StretchBlt API to draw Form1 on Form2
lRet = StretchBlt(Form2.Picture1.hDC, lx, 0, -lx, ly&, _
Me.hDC, 0, 0, lx&, ly&, SRCCOPY)

' Set the AutoRedraw back to false and refresh
Form2.Picture1.AutoRedraw = False
Call
Form2.Picture1.Refresh

' resize Form2 to the size of Form1 and Show the form
Call Form2.Move(Form2.Left, Form2.Top, Me.Width, Me.Height)
Call Form2.Show

End Sub

Private Sub
Form_Load()
Command1.Caption = "Flip The Form"
End Sub

Step 7: Paste This code in Form2
Option Explicit

Private Sub
Form_Load()
' Set BorderStyle to none
Picture1.BorderStyle = 0
End Sub

Private Sub
Form_Resize()
On Error Resume Next
' resize the picture to fit form area
Call Picture1.Move(0, 0, Me.ScaleWidth, Me.ScaleHeight)
End Sub

Then Run or press F5 and then Click on the "Flip The Form" button to see it. Observe how I simply use StretchBlt API to flip the form image. I hope this code will help you. Enjoy!

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy




March 27, 2007

1

How to Add XP Visual Style to your Visual Basic Application

Recently, I got some friends asking me about how can they add Windows XP visual style on their Visual Basic application.

Why can't you get the XP style look when you run or compile your Visual Basic application anyway? For your information, the Windows XP Visual Styles are provided by ComCtl32.dll version 6 or later. The ComCtl32 does not apply the latest styles to the client area of an application by default. So, in order to enable it, you need to ensure that your application is linked to the new ComCtl32.dll by calling the ComCtl's InitCommonControls API call. And then, you also need to provide a Manifest file which specifies that the new version of the control styles should be used.

To make this short. All you need to add to your code is this lines of codes on a module...

Private Type tagInitCommonControlsEx
lSize As Long
lICC As Long
End Type

Private Declare Function
InitCommonControlsEx Lib "comctl32.dll" _
(iccex As tagInitCommonControlsEx) As Boolean
Private Const
ICC_USEREX_CLASSES = &H200

Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim
iccex As tagInitCommonControlsEx

With iccex
.lSize = LenB(iccex)
.lICC = ICC_USEREX_CLASSES
End With
InitCommonControlsEx iccex
InitCommonControlsVB = (Err.Number = 0)
On Error Goto 0
End Function


Public Sub Main()
' Call the function before other codes
InitCommonControlsVB
'
' Start your application here:
'

End Sub

Then add this text in a text file...

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourAppName"
type="win32" />
<description>Your application description here
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>

and rename the text file to 'yourexefilename.exe.manifest' and save it in the same folder with your exe file. Also make sure that your application Startup Object is Sub Main (check this in Project > [your app] Properties).

That's all. You can see your application is using XP Style after you compile it and run it outside Visual Basic. You can't see the changes if you run it using Visual Basic.

You can also get detail explanation on this at vbAccelerator. Enjoy!

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

March 24, 2007

0

What the heck about the Pentium?

Hoh! Hoh!... I recently got back my old unused Pentium III PC from my big brother, Arlong. He borrowed the PC since I bought my Hewlett Packard Notebook. Then, I'm thinking about upgrading this PC to do my 'underground project' Heheh!... I'm thinking about getting a new Pentium Dual Core processor and a big RAM for it. So, I surely have to change the motherboard. Hmm... This PC reminds me about my good old programming day while I'm studying at UTM-EDI. Sitting at my desk with my big DIY speakers (according to my brother, the power supply for the power amp have blown)... And I still remember the day that I really enjoyed Weird Al Yankovic songs... Win95 sucks and so on...

Owh!... for those whe haven't heard about Weird Al Yankovic, I still have the lyrics and recently I found the Video clip of his good old song called 'It's All About The Pentiums'... Enjoy, and have fun!




Here's the lyrics...
Weird Al Yankovic - It's All About The Pentiums

It's all about the Pentiums, baby
Uhh, uh-huh, yeah
Uhh, uh-huh, yeah
It's all about the Pentiums, baby
It's all about the Pentiums, baby
It's all about the Pentiums!
It's all about the Pentiums!
(Yeah!!)

What y'all wanna do?
Wanna be hackers? Code crackers? Slackers
Wastin' time with all the chatroom yakkers?
9 to 5, chillin' at Hewlett Packard?
Workin' at a desk with a dumb little placard?
Yeah, payin' the bills with my mad programming skills
Defraggin' my hard drive for thrills
I got me a hundred gigabytes of RAM
I never feed trolls and I don't read spam
Installed a T1 line in my house
Always at my PC, double-clickin' on my mizouse*
Upgrade my system at least twice a day
I'm strictly plug-and-play, I ain't afraid of Y2K
I'm down with Bill Gates, I call him Money for short
I phone him up at home and I make him do my tech support
It's all about the Pentiums, what?
You gotta be the dumbest newbie I've ever seen
You've got white-out all over your screen
You think your Commodore 64 is really neato
What kinda chip you got in there, a Dorito?
You're usin' a 286? Don't make me laugh
Your Windows boots up in what, a day and a half?
You could back up your whole hard drive on a floppy diskette
You're the biggest joke on the Internet
Your database is a disaster
You're waxin' your modem, tryin' to make it go faster
Hey fella, I bet you're still livin' in your parents' cellar
Downloadin' pictures of Sarah Michelle Gellar
And postin' "Me too!" like some brain-dead AOL-er
I should do the world a favor and cap you like Old Yeller
You're just about as useless as jpegs to Helen Keller

It's all about the Pentiums! (yeay!)
It's all about the Pentiums! (yeay!)
It's all about the Pentiums! (yeay!)
It's all about the Pentiums! (yeay!)

What y'all wanna do?


Wanna be hackers? Code crackers? Slackers
Wastin' time with all the chatroom yakkers?
9 to 5, chillin' at Hewlett Packard?

Uh, uh, loggin' in now
Wanna run wit my crew, hah?
Rule cyberspace and crunch numbers like I do?
They call me the king of the spreadsheets
Got'em all printed out on my bedsheets
My new computer's got the clocks, it rocks
But it was obsolete before I opened the box
You say you've had your desktop for over a week?
Throw that junk away, man, it's an antique!

Your laptop is a month old? Well, that's great
If you could use a nice, heavy paperweight
My digital media is write-protected
Every file inspected, no viruses detected
I beta tested every operating system
Gave props to some, and others? I dissed'em
While your computer's crashin', mine's multitaskin'
It does all my work without me even askin'
Got a flat-screen monitor, 40" wide
I believe that yours says, "Etch-A-Sketch" on the side
In a 32-bit world, you're a 2-bit user
You've got your own newsgroup, alt.total-loser
Your motherboard melts when you try to send a fax
Where'd you get your CPU, in a box of Cracker Jacks?
Play me online? Well, you know that I'll beat you
If I ever meet you I'll control-alt-delete you
What?

It's all about the Pentiums!
It's all about the Pentiums!
It's all about the Pentiums!
It's all about the Pentiums!

What y'all wanna do?
Wanna be hackers? Code crackers? Slackers
Wastin' time with all the chatroom yakkers?
9 to 5, chillin' at Hewlett Packard?
What?

* Mizouse - means mouse according to Urban Dictionary

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy




March 23, 2007

0

Database Development: GUIDs or IDs as Primary Key?

I got quite busy so I didn't have enough time to post in this blog. Currently, I'm coding for another monitoring system device that will work in parallel with my last visual basic development on vibration monitoring. Today, I'm dealing with MySQL database that will keep all the measurement data will be updated in real time.

Something that I found on my reader today catch my interest where Jeff Atwood wrote about wether to use IDs or GUIDs for database primary keys. Before you're asking me. GUID or Globally Unique Identifier is a pseudo-random number used in software applications. The difference between normal IDs that usually in form of auto increment integer value...

ID  Value
-- -----
1 Visual Basic Programming
2 Visual C++ Programming
3 VB .NET Programming
4 C# .NET Programming
5 Java Programming

and GUID keys which most commonly written in text as a sequence of hexadecimal digits...
ID                                    Value
------------------------------------ -----
C84AC87F-842C-20EF-4D77-9F8429E95131 Visual Basic Programming
4AE8DEE4-501E-47EE-51A8-365AC5A069AC Visual C++ Programming
60E22A73-8677-4630-B3CB-12131D16635C VB .NET Programming
1515ED8C-823C-0166-8417-295981EA7158 C# .NET Programming
ED15158C-3C66-3F82-EE34-81295589EF43 Java Programming

as your database primary keys is the GUIDs will be unique across every table, every database and every server you have. This means you can easily merge records from different databases. Anyway, there is still a lot of pros and cons of using such 16-bytes GUIDs as discussed in..


But from now on, you have another option to choose for your database development.

Owh.. before I forget, as usual I'll offer great books for you to have. So, take a look at this reference manual... and enjoy!!

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

March 8, 2007

0

The Next Generation's Baby

Today's kid are born with computer around them. It is easier to tell kid about computer than their parents.


Baby's First Language

Lately, I'm trying to do some java web application.

Share This Article:


Bookmark This Article:
Feed Me Digg Technorati del.icio.us Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy