Search for directory default browser

Diposting oleh Source Code Program | 19.14 | | 0 komentar »

"Search for directory default browser

Option Explicit
Private Declare Function FindExecutable Lib "shell32.dll" _
Alias "FindExecutableA" _
(ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal sResult As String) As Long

Private Const MAX_PATH As Long = 260
Private Const ERROR_FILE_SUCCESS As Long = 32

Private Function GetBrowserName(dwFlagReturned As Long) As String

Dim l_hFile As Long
Dim sResult As String

"html file created while the later will be called
sResult = Space$(MAX_PATH)
dwFlagReturned = FindExecutable("dummy.html", App.Path, sResult)

"delete a file that is created
Kill App.Path & "\dummy.html"

"capture the location of executable files and dispose of character carridge return
GetBrowserName = TrimNull(sResult)

End Function

Private Sub Command1_Click()

Dim l_Temp As Long
Dim sBrowser As String

sBrowser = GetBrowserName(l_Temp)

Select Case l_Temp
Case Is >= ERROR_FILE_SUCCESS
MsgBox "Location of default browser: " & sBrowser, vbInformation
Case Else
MsgBox "Can't find default browser", vbInformation
End Select
End Sub




Sempel visual basic code soutrce Mouse Pointer in the middle of control
Sub CenterCursor(hWnd As Long)
Dim rPosition As RECT
#If Win32 Then
Dim X As Long
Dim Y As Long
#Else
Dim X As Integer
Dim Y As Integer
#End If

GetWindowRect hWnd, rPosition
X = (rPosition.right + rPosition.left) / 2
Y = (rPosition.bottom + rPosition.top) / 2
SetCursorPos X, Y
End Sub

CenterCursor hWnd:=Command1.hWnd

Sempel visual basic code soutrce Mouse Pointer in the middle of control

#If Win32 Then
Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Declare Sub GetWindowRect Lib "User32" (ByVal hWnd As _
Long, lpRect As RECT)
Declare Sub SetCursorPos Lib "User32" (ByVal X As _
Long, ByVal Y As Long)
#Else
Type RECT
left As Integer
top As Integer
right As Integer
bottom As Integer
End Type

Declare Sub GetWindowRect Lib "User" (ByVal hWnd _
As Integer, lpRect As RECT)
Declare Sub SetCursorPos Lib "User" (ByVal X As _
Integer, ByVal Y As Integer)
#End If

vb connection example using app.path

Diposting oleh Source Code Program | 00.55 | | 0 komentar »

Private Sub DataEnvironment_Initialize()
' The re-connection
Connection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data " _
"Source=C:\nc\ims.mdb "
End Sub

Window Status Bar - Link change

Diposting oleh Source Code Program | 18.51 | | 0 komentar »

<HTML>
<HEAD>
<TITLE>default Text in the Status Bar when mouse cursor is
over link</TITLE>
</HEAD>
<BODY>
Look in the status Bar and put mouse cursor over link<BR>
Planet source code<BR>
All the script is in the body of the document too!<BR><BR>
<A href="http://www.komputerprogramming.blogspot.com"
onMouseover="window.status='One of the best
places to post/get code to/from on the net!';return true"
onMouseout="window.status='';return true">'mouse over' this!</A>
</BODY>
</HTML>

Right click disabler

Diposting oleh Source Code Program | 18.26 | | 0 komentar »

sempel source code click right diabled

<HTML>
<HEAD>
<TITLE>Just try to right click on me</TITLE>
</HEAD>
<SCRIPT>
<!-- JavaScript Start -----
function click() {if (event.button==2) { alert('Disabled') } }
document.onmousedown=click
----- JavaScript End ------>
</SCRIPT>
<BODY>
Just try to right click
</BODY>
</HTML>

Area Of Circle Calculator

Diposting oleh Source Code Program | 01.45 | | 0 komentar »

Private Sub Command1_Click()


Dim Radius
Radius = InputBox("Type In The Radius", "Radius")
Dim Area
Area = 3.14 * (Radius * Radius)
MsgBox Area, vbDefaultButton1, "Answer"

Dim Answer


End Sub

CHANGE AOL'S WELCOME MENU'S CAPTION

Diposting oleh Source Code Program | 01.41 | | 0 komentar »

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Declare Function sendmessagebystring Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Const WM_SETTEXT = &HC


Function FindChildByClass(parentw, childhand)

firs% = GetWindow(parentw, 5)
If UCase(Mid(GetClass(firs%), 1, Len(childhand))) Like UCase(childhand) Then Goto bone
firs% = GetWindow(parentw, GW_CHILD)
If UCase(Mid(GetClass(firs%), 1, Len(childhand))) Like UCase(childhand) Then Goto bone


While firs%
firss% = GetWindow(parentw, 5)
If UCase(Mid(GetClass(firss%), 1, Len(childhand))) Like UCase(childhand) Then Goto bone
firs% = GetWindow(firs%, 2)
If UCase(Mid(GetClass(firs%), 1, Len(childhand))) Like UCase(childhand) Then Goto bone
Wend

FindChildByClass = 0
bone:
room% = firs%
FindChildByClass = room%
End Function



Function FindChildByTitle(parentw, childhand)

firs% = GetWindow(parentw, 5)
If UCase(GetCaption(firs%)) Like UCase(childhand) Then Goto bone
firs% = GetWindow(parentw, GW_CHILD)


While firs%
firss% = GetWindow(parentw, 5)
If UCase(GetCaption(firss%)) Like UCase(childhand) & "*" Then Goto bone
firs% = GetWindow(firs%, 2)
If UCase(GetCaption(firs%)) Like UCase(childhand) & "*" Then Goto bone
Wend

FindChildByTitle = 0
bone:
room% = firs%
FindChildByTitle = room%
End Function



Sub RenameWelcomeWindow(NewCaption As String)

ao% = FindWindow("AOL Frame25", vbNullString)
bb% = FindChildByClass(ao%, "MDIClient")
arf = FindChildByTitle(bb%, "Welcome, ")
Call ChangeWindowCap(arf, NewCaption)
End Sub



Sub ChangeWindowCap(WindowClassName, NewName As String)

b = sendmessagebystring(WindowClassName, WM_SETTEXT, 0, NewName)
End Sub

Sub Command1_Click ()

RenameWelcomeWindow("New Welcome Menu Caption")
End Sub


info: planetsourcecode.com

Random String Generator With Patterns and Extra Options

Diposting oleh Source Code Program | 01.32 | | 0 komentar »

Name : Random String Generator With Patterns and Extra Options
Description :Creates Random Strings of a specific length. There r sum options that u can use, and u can set ur own pattern. So, it can b pretty useful. Hope it is. :) if u want to c the code implemented in a Program, u can take a look at mycode example that i submitted. I'll put the link when i get it.

Function GenStr(MaxLen,Restrictions:Integer):String;Overload;
{Possible Resctiction Values:
1 - All
2 - Just Letters and Numbers
3 - Just Numbers
4 - Just Letters
}
Var St:Byte;
Total:String;
begin
Repeat
Randomize;
St := Random(255);
// All Caracters
If Restrictions = 1 then
Total := Total + chr(St);
//Just Letters and Numbers
If Restrictions = 2 then
If (St >= 48) and (St <= 57) or (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122) then
Total := Total + chr(St);
//Just Numbers
If Restrictions = 3 then
If (St >= 48) and (St <= 57) then
Total := Total + chr(St);
//Just Letters
If Restrictions = 4 then
If (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122) then
Total := Total + chr(St);
Until Length(Total) = MaxLen;
Result := Total;
end;
Function GenStr(MaxLen:Integer;Pattern:String):String;Overload;
{Possible Resctiction Values:
1 - All
2 - Just Letters and Numbers
3 - Just Numbers
4 - Just Letters
Possble Pattern Parameters:
A or a - All
L - Letter In Capitals
l - Letter not in capitals
C or c - Character ( A,B or a,b (etc.))
N or n - Numbers
R or r - Random Generated Pattern
Ex:
If u wanted a generated string that was Number, number,number,Captiol
letter then any letter, u would use this pattern:
NNNLC or NNNLc
}
Var St:Byte;
Total:String;
Ptrn:String;
P:Byte;
PtrnCount:Integer;
begin
//If pattern is set to random, we need to make a pattern ourselves
If (Pattern = 'R') or (Pattern = 'r') then
Begin
repeat
//Get ready for random
Randomize;
//Get random number
P := Random(225);
//Check to c if its a pattern number or not (ASCII values of A,N,L,l,etc.
Case P of
//A or a
65 or 97:Ptrn := Ptrn + 'A';
//L
78:Ptrn := Ptrn + 'L';
//l
108:Ptrn := Ptrn + 'l';
//C or c
67 or 99:Ptrn := Ptrn + 'C';
//N or n
78 or 110:Ptrn := Ptrn + 'N';
end;
until Length(Ptrn) = (MaxLen div 2) + 1;
//Set the New Pattern
Pattern := Ptrn;
end;
//String Generation Section
PtrnCount := 0;
Repeat
//Prepare to random
Randomize;
//Add 1 to PtrnCount
Inc(PtrnCount);
//A or a //Everything Is OK
If (Pattern[PtrnCount] = 'A') or (Pattern[PtrnCount] = 'a') then
Total := Total + chr(Random(255));
//L //Just Capitol Letters
If (Pattern[PtrnCount] = 'L') then
Begin
Repeat
//Get random number
St := Random(255);
Until (St >= 65) and (St <= 90);
Total := Total + chr(St);
end;
//l //Letters, but not it capitols
If (Pattern[PtrnCount] = 'l') then
Begin
Repeat
//Get random number
St := Random(255);
Until (St >= 97) and (St <= 122);
Total := Total + chr(St);
end;
//C or c //Any letter, wether its a capitol or not
If (Pattern[PtrnCount] = 'C') or (Pattern[PtrnCount] = 'c') then
begin
Repeat
//Get random number
St := Random(255);
Until (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122);
Total := Total + chr(St);
end;
//N or n //Number
If (Pattern[PtrnCount] = 'N') or (Pattern[PtrnCount] = 'n') then
begin
Repeat
//Get random number
St := Random(255);
Until (St >= 48) and (St <= 57);
Total := Total + chr(St);
end;
//IF PtrnCount is at it's max, reset it
If PtrnCount = Length(Pattern) then
PtrnCount := 0;
Until Length(Total) = MaxLen;
Result := Total;
end;

info : planetsorcecode.com

Page Properties and Printing

Diposting oleh Source Code Program | 00.45 | | 0 komentar »

Set Print Titles

The print titles function allows you to repeat the column and row headings at the beginning of each new page to make reading a multiple page sheet easier to read when printed. To Print Titles:

  • Click the Page Layout tab on the Ribbon
  • Click the Print Titles button
  • In the Print Titles section, click the box to select the rows/columns to be repeated
  • Select the row or column
  • Click the Select Row/Column Button
  • Click OK

Create a Header or Footer
To create a header or footer:

  • Click the Header & Footer button on the Insert tab
  • This will display the Header & Footer Design Tools Tab
  • To switch between the Header and Footer, click the Go to Header or Go to Footer button
  • To insert text, enter the text in the header or footer
  • To enter preprogrammed data such as page numbers, date, time, file name or sheet name, click the appropriate button
  • To change the location of data, click the desired cell



Set Page Margins
To set the page margins:

  • Click the Margins button on the Page Layout tab
  • Select one of the give choices, or
  • Click Custom Margins
  • Complete the boxes to set margins
  • Click Ok

Change Page Orientation
To change the page orientation from portrait to landscape:

  • Click the Orientation button on the Page Layout tab
  • Choose Portrait or Landscape

Set Page Breaks
You can manually set up page breaks in a worksheet for ease of reading when the sheet is printed. To set a page break:

  • Click the Breaks button on the Page Layout tab
  • Click Insert Page Break

Print a Range
There may be times when you only want to print a portion of a worksheet. This is easily done through the Print Range function. To print a range:

  • Select the area to be printed
  • Click the Print Area button on the Page Layout tab
  • Click Select Print Area

Sort and Filter office 2007

Diposting oleh Source Code Program | 00.31 | | 0 komentar »

Sorting and Filtering allow you to manipulate data in a worksheet based on given set of criteria.

Basic Sorts
To execute a basic descending or ascending sort based on one column:

  • Highlight the cells that will be sorted
  • Click the Sort & Filter button on the Home tab
  • Click the Sort Ascending (A-Z) button or Sort Descending (Z-A) button

Custom Sorts

To sort on the basis of more than one column:

  • Click the Sort & Filter button on the Home tab
  • Choose which column you want to sort by first
  • Click Add Level
  • Choose the next column you want to sort
  • Click OK

Filtering
Filtering allows you to display only data that meets certain criteria. To filter:

  • Click the column or columns that contain the data you wish to filter
  • On the Home tab, click on Sort & Filter
  • Click Filter button
  • Click the Arrow at the bottom of the first cell
  • Click the Text Filter
  • Click the Words you wish to Filter
  • To clear the filter click the Sort & Filter button
  • Click Clear
info :www.fgcu.edu



Add a horizontal scrollbar to a listbox

Diposting oleh Source Code Program | 05.53 | | 0 komentar »

procedure TForm1.Timer1Timer(Sender: TObject);

var

i,len,width: integer;

begin

with listbox1 do

begin

width := 0;

for i := 0 to items.count -1 do

begin

len := canvas.textwidth(items[i]);

if len > width then width := len;

end;

//set listbox's horizontal scrollbar width

Perform(LB_SETHORIZONTALEXTENT,width+100,0);

end;

end;

access application information programmatically

Diposting oleh Source Code Program | 05.22 | | 0 komentar »

This function will read the file version information from your application's executable file. It does this through the Win32 API functions GetFileVersionInfoSize(), GetFileVersionInfo(), and VerQueryValue(). This can be very useful if you have your IDE set to increment build numbers each time you compile your project, as it can be used to return the current version number. Since I use the version number in a lot of my applications, it's really a pain to have to update a global constant each time the version number changes. This makes it much easier. Please note: I found a version of this code in the Borland Delphi 6 help files, and modified it so it would be a function, and return only the file version information. Additionally, there were very few comments, so I commented much of the code as well. You can view the original code if you do a search in the help files for "Reading version information".

function Application_Version: String;
const
InfoNum = 10;
InfoStr: array[1..InfoNum] of string = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFileName', 'ProductName', 'ProductVersion', 'Comments');
var
S: string; n, Len, i: DWORD;
Buf: PChar; Value: PChar;
begin
S := Application.ExeName; //this application's EXE filename
n := GetFileVersionInfoSize(PChar(S), n); // the return value is the size in bytes of the file's version information.
Result := ''; (* this sets a default result in case a file version isn't found.
I add this to functions because the compiler will bug you that
the result may not be defined otherwise. you could change this,
or remove it alltogether, although it's probably best to leave it. *)
if n > 0 then begin
Buf := AllocMem(n); // allocate the needed amount of memory into the buffer
GetFileVersionInfo(PChar(S), 0, n, Buf); // store the file version information in the memory buffer. it stores all of the values listed in the InfoStr array.
for i := 1 to InfoNum do
if VerQueryValue(Buf, PChar('StringFileInfo\040904E4\' + InfoStr[i]), Pointer(Value), Len) then
if trim(lowerCase(InfoStr[i])) = 'fileversion' then Result := Value;// loop through each value until we find the "FileVersion" information.
FreeMem(Buf, n); // free the memory we stored in the buffer.
end;
end;

Your Complex Number Class

Diposting oleh Source Code Program | 05.20 | | 0 komentar »

Your Complex Number Class
Imports System

Public Class MainClass

Shared Sub Main(ByVal args As String())
Dim X, Y As Complex
X = New Complex(1, 2)
Y = New Complex(3, 4)

Console.WriteLine( (X + Y).ToString )
Console.WriteLine( (X - Y).ToString )
Console.WriteLine( (X * Y).ToString )
Console.WriteLine( (X = Y).ToString )
Console.WriteLine( (X <> Y).ToString )
Console.WriteLine( (-X).ToString )
Dim abs_x As Double = CDbl(X)
Console.WriteLine( abs_x.ToString )
End Sub

End Class

Public Class Complex
Public realPart As Double
Public imaginaryPart As Double

' Constructors.
Public Sub New()
End Sub
Public Sub New(ByVal real_part As Double, ByVal imaginary_part As Double)
realPart = real_part
imaginaryPart = imaginary_part
End Sub

' ToString.
Public Overrides Function ToString() As String
Return realPart.ToString & " + " & imaginaryPart.ToString & "i"
End Function

' Operators.
Public Shared Operator *(ByVal c1 As Complex, ByVal c2 As Complex) As Complex
Return New Complex( _
c1.realPart * c2.realPart - c1.imaginaryPart * c2.imaginaryPart, _
c1.realPart * c2.imaginaryPart + c1.imaginaryPart * c2.realPart)
End Operator
Public Shared Operator +(ByVal c1 As Complex, ByVal c2 As Complex) As Complex
Return New Complex( _
c1.realPart + c2.realPart, _
c1.imaginaryPart + c2.imaginaryPart)
End Operator
Public Shared Operator -(ByVal c1 As Complex, ByVal c2 As Complex) As Complex
Return New Complex( _
c1.realPart - c2.realPart, _
c1.imaginaryPart - c2.imaginaryPart)
End Operator
Public Shared Operator =(ByVal c1 As Complex, ByVal c2 As Complex) As Boolean
Return (c1.realPart = c2.realPart) AndAlso (c1.imaginaryPart = c2.imaginaryPart)
End Operator
Public Shared Operator <>(ByVal c1 As Complex, ByVal c2 As Complex) As Boolean
Return (c1.realPart <> c2.realPart) OrElse (c1.imaginaryPart <> c2.imaginaryPart)
End Operator
Public Shared Operator -(ByVal c1 As Complex) As Complex
Return New Complex(c1.imaginaryPart, c1.realPart)
End Operator
Public Shared Narrowing Operator CType(ByVal c1 As Complex) As Double
Return System.Math.Sqrt(c1.realPart * c1.realPart + c1.imaginaryPart * c1.imaginaryPart)
End Operator
End Class

Nested Class Demo

Diposting oleh Source Code Program | 05.10 | | 0 komentar »

Nested Class Demo
Public Class Fraction
Private numerator As Integer
Private denominator As Integer

Public Sub New( _
ByVal numerator As Integer, ByVal denominator As Integer)
Me.numerator = numerator
Me.denominator = denominator
End Sub 'New

Public Overrides Function ToString( ) As String
Return [String].Format("{0}/{1}", numerator, denominator)
End Function 'ToString

' Nested Class
Class FractionArtist
Public Sub Draw(ByVal f As Fraction)
Console.WriteLine("Drawing the numerator: {0}", f.numerator)
Console.WriteLine( _
"Drawing the denominator: {0}", f.denominator)
End Sub 'Draw
End Class 'FractionArtist

End Class 'Fraction

Hide the Mouse Pointer

Diposting oleh Source Code Program | 05.02 | | 0 komentar »

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

history programming VB

Diposting oleh Source Code Program | 21.29 | | 0 komentar »

Visual Basic

What is Visual Basic?
Visual Basic is a "visual programming" environment for developing Windows (also Web now) applications. Visual Basic makes it possible to develop complicated applications very quickly. The programmer designs windows graphically, drags program elements from the Visual Basic Toolbox and writes basic code for each element. Visual Basic is " event driven" which means that procedures are called automatically when the end user chooses menu items, clicks the mouse, moves objects on the screen, etc.

Why is Visual Basic popular?
Programmers have undergone a major change in many years of programming various machines. For example, what could take days to create an application in other programming languages like C, C++ could be done in hours with Visual Basic. Visual Basic provides many interesting sets of tools to aid us in building exciting applications. Visual Basic provides these tools to make our life far more easier because all the real hard code is already written for us.
Visual Basic is not only a programming language but also a true graphical development environment. This environment allows programmers with little programming experience to quickly develop powerful Windows applications. Visual Basic also has the ability to develop programs that can be used as a front-end application to a database system, serving as the user interface which collects user input and displays formatted output in a more appealing and useful form.
Visual Basic is very popular for the ease with which it allows the programmer to create nice looking graphical programs with less coding unlike many other languages that take thousands of lines of programmer keyed code. As the programmer works in the graphical environment much of the program code is automatically generated by the Visual Basic program.

Areas of Use
Using Visual Basic's tools we can quickly translate an abstract idea into a program design that we can actually see on the screen. VB encourages you to experiment, revise, correct, and network your design until the new project meets your requirements. However, most of all, it inspires your imagination and creativity. Visual Basic is ideal for developing applications that run on the Windows operating system. Developing applications with VB can be said to be a 3-step approach:
1) Design the appearance of application
2) Assign property settings to the objects of the program
3) Write the code to direct specific tasks at runtime
Visual Basic is used to develop applications in a number of different areas. Some of them are listed below:
• Accounting
• Business
• Commerce
• Consulting
• Education
• Law
• Marketing and Sales
• Medicine
• Research
• Science
Many of the things that we do with Visual Basic really aren’t very basic. The Visual Basic language is powerful, if you can imagine a programming task, it can be accomplished using Visual Basic.
History of Visual Basic
Microsoft first released Visual Basic in 1987. It was the first visual development tool from Microsoft, and it was to compete with C, C++, Pascal and other well-known programming languages. From the start, Visual Basic wasn't a hit. It wasn't until release 2.0 that people really discovered the potential of the language, and with release 3.0 it had become the fastest-growing programming language on the market.
Below is the order and the approximate year in which a new version of Visual Basic was released:
• 1991, VB1 Debuts
• 1992, VB2 Debuts
• 1993, VB3 Debut
• 1996, VB4 Debuts
• 1997, VB5 Debuts
• 1998, VB6 Debuts
• 2001, VB. NET Debuts

Select Case Err Number

Diposting oleh Source Code Program | 16.25 | | 0 komentar »

Imports System.IO

public class Tester
public Shared Sub Main

On Error GoTo ErrorHandle
Exit Sub

ErrorHandle:
Select Case Err.Number
Case 52
Console.WriteLine("File Name Exception")
Case 53
Console.WriteLine("File cannot be found")
Case 54
Console.WriteLine("File Mode Exception")
Case 55
Console.WriteLine("File is aleady open")
Case 58
Console.WriteLine("File exists")
Case 68
Console.WriteLine("Device is not available")
Case 75
Console.WriteLine("Path Exception")
Case 76
Console.WriteLine("Path cannot be found")
Case Else
Console.WriteLine("Other")
End Select

End Sub

End class

On Error GoTo errorhandle

Diposting oleh Source Code Program | 16.19 | | 0 komentar »

Imports System.IO

public class Tester
public Shared Sub Main

Dim myfile As System.IO.File
Dim w As System.IO.StreamWriter
On Error GoTo errorhandle

w = myfile.AppendText("a:\temp.txt")
w.Write("a")
w.Close()
Exit Sub

errorhandle:
Console.WriteLine("Please Insert")
Exit Sub
Resume
End Sub

End class

Simple Stopwatch

Diposting oleh Source Code Program | 16.09 | | 0 komentar »

In this tutorial we'll be learning how to make a simple stopwatch.

2 Labels with:

#1 Label:
Name: Label1
Caption: SIMPLE STOPWATCH

#2 Label:
Name: Label2
Caption: 0.00

4 Command Buttons with:

#1 Command Button:
Name: Command1
Caption: START

#2 Command Button:
Name: Command2
Caption: STOP

#3 Command Button:
Name: Command3
Caption: RESET

#4 Command Button:
Name: Command4
Caption: QUIT

1 Timer with:
Name: Timer1
Caption: (None)
Interval: 1

Code
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Command3_Click()
Label2.Caption = "0.00"
End Sub

Private Sub Command4_Click()
End
End Sub

Private Sub Timer1_Timer()
Label2.Caption = Format(Val(Label2.Caption) + 0.01, _
"fixed")
End Sub

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Command3_Click()
Label2.Caption = "0.00"
End Sub

Private Sub Command4_Click()
End
End Sub

Private Sub Timer1_Timer()
Label2.Caption = Format(Val(Label2.Caption) + 0.01, _
"fixed")
End Sub

This means make Label2's caption change by adding +0.01 to it every millisecond.

String Handling

Diposting oleh Source Code Program | 16.06 | | 0 komentar »

Explanation:

1. InStr is a function that looks for the position of a substring in a phrase.

InStr(phrase,"ual") will find the substring "ual" from "Visual Basic" and then return its position, in this case, it is 4 from the left.

2. Left is a function that extracts characters from a phrase, starting from the left. Left(phrase,4) means 4 characters are extracted from the phrase, starting from the leftmost position.

3. Right is a function that extracts characters from a phrase, starting from the Right. Right(phrase,5) means 5 characters are extracted from the phrase, starting from the rightmost position.

4. Mid is a function that extracts a substring from a phrase, starting from the posiiton specified by the second parameter in the bracket.Mid(phrase,8,3) means a substring of three characters are extracted from the phrase, starting from the 8th position from the left

5. Len is a function that return the length of a phrase.

Private Sub cmdInstr_Click()
Dim phrase As String
phrase = Cells(1, 1).Value
Cells(4, 1) = InStr(phrase, "ual")
End Sub

Private Sub cmdLeft_Click()
Dim phrase As String
phrase = Cells(1, 1).Value
Cells(2, 1) = Left(phrase, 4)

End Sub

Private Sub cmdLen_Click()
Dim phrase As String
phrase = Cells(1, 1).Value
Cells(6, 1) = Len(phrase)
End Sub

Private Sub cmdMid_Click()
Dim phrase As String
phrase = Cells(1, 1).Value
Cells(5, 1) = Mid(phrase, 8, 3)
End Sub

Private Sub cmdRight_Click()
Dim phrase As String
phrase = Cells(1, 1).Value
Cells(3, 1) = Right(phrase, 5)

COOL FORM CLOSER

Diposting oleh Source Code Program | 22.00 | | 0 komentar »

Private Sub Label1_Click()

Top = (Screen.Height - Width) / 1
Left = (Screen.Width - Height) / 2
Top = (Screen.Height - Width) / 3
Left = (Screen.Width - Height) / 4
Top = (Screen.Height - Width) / 5
Left = (Screen.Width - Height) / 6
Top = (Screen.Height - Width) / 7
Left = (Screen.Width - Height) / 8
Top = (Screen.Height - Width) / 9
Top = (Screen.Height - Width) / 10
Left = (Screen.Width - Height) / 12
Top = (Screen.Height - Width) / 13
Left = (Screen.Width - Height) / 14
Top = (Screen.Height - Width) / 15
Left = (Screen.Width - Height) / 16
Top = (Screen.Height - Width) / 17
Left = (Screen.Width - Height) / 18
Top = (Screen.Height - Width) / 19
Left = (Screen.Width - Height) / 20
Top = (Screen.Height - Width) / 21
Left = (Screen.Width - Height) / 22
Top = (Screen.Height - Width) / 23
Left = (Screen.Width - Height) / 24
Top = (Screen.Height - Width) / 25
Left = (Screen.Width - Height) / 26
Top = (Screen.Height - Width) / 27
Left = (Screen.Width - Height) / 28
Top = (Screen.Height - Width) / 29
Left = (Screen.Width - Height) / 30
Top = (Screen.Height - Width) / 31
Left = (Screen.Width - Height) / 32
Top = (Screen.Height - Width) / 31
Top = (Screen.Height - Width) / 30
Left = (Screen.Width - Height) / 29
Top = (Screen.Height - Width) / 28
Left = (Screen.Width - Height) / 27
Top = (Screen.Height - Width) / 26
Left = (Screen.Width - Height) / 25
Top = (Screen.Height - Width) / 24
Left = (Screen.Width - Height) / 23
Top = (Screen.Height - Width) / 22
Top = (Screen.Height - Width) / 21
Left = (Screen.Width - Height) / 20
Top = (Screen.Height - Width) / 19
Left = (Screen.Width - Height) / 18
Top = (Screen.Height - Width) / 17
Left = (Screen.Width - Height) / 16
Top = (Screen.Height - Width) / 15
Left = (Screen.Width - Height) / 14
Top = (Screen.Height - Width) / 13
Left = (Screen.Width - Height) / 12
Top = (Screen.Height - Width) / 11
Left = (Screen.Width - Height) / 10
Top = (Screen.Height - Width) / 9
Left = (Screen.Width - Height) / 8
Top = (Screen.Height - Width) / 7
Left = (Screen.Width - Height) / 6
Top = (Screen.Height - Width) / 5
Left = (Screen.Width - Height) / 4
Top = (Screen.Height - Width) / 3
Left = (Screen.Width - Height) / 2
Top = (Screen.Width + Height) / 2
Left = (Screen.Height + Width) / 3
Top = (Screen.Width + Height) / 4
Left = (Screen.Height + Width) / 5
Top = (Screen.Width + Height) / 6
Left = (Screen.Height + Width) / 7
Top = (Screen.Width + Height) / 8
Left = (Screen.Height + Width) / 9
Top = (Screen.Width + Height) / 10
Left = (Screen.Height + Width) / 11
Top = (Screen.Width + Height) / 12
Left = (Screen.Height + Width) / 13
Top = (Screen.Width + Height) / 14
Left = (Screen.Height + Width) / 15
Top = (Screen.Width + Height) / 16
Left = (Screen.Height + Width) / 17
Top = (Screen.Width + Height) / 18
Left = (Screen.Height + Width) / 19
Top = (Screen.Width + Height) / 20
Left = (Screen.Height + Width) / 21
Top = (Screen.Width + Height) / 22
Left = (Screen.Height + Width) / 23
Top = (Screen.Width + Height) / 24
Left = (Screen.Height + Width) / 25
Top = (Screen.Width + Height) / 26
Left = (Screen.Height + Width) / 27
Top = (Screen.Width + Height) / 28
Left = (Screen.Height + Width) / 29
Top = (Screen.Width + Height) / 30
Left = (Screen.Height + Width) / 31
Top = (Screen.Width + Height) / 32
Left = (Screen.Height + Left) / 31
Top = (Screen.Width + Top) / 30
Left = (Screen.Height + Left) / 29
Top = (Screen.Width + Top) / 28
Left = (Screen.Height + Left) / 27
Top = (Screen.Width + Top) / 26
Left = (Screen.Height + Left) / 25
Top = (Screen.Width + Top) / 24
Left = (Screen.Height + Left) / 23
Top = (Screen.Width + Top) / 22
Left = (Screen.Height + Left) / 21
Top = (Screen.Width + Top) / 20
Left = (Screen.Height + Left) / 19
Top = (Screen.Width + Top) / 18
Left = (Screen.Height + Left) / 17
Top = (Screen.Width + Top) / 16
Left = (Screen.Height + Left) / 15
Top = (Screen.Width + Top) / 14
Left = (Screen.Height + Left) / 13
Top = (Screen.Width + Top) / 12
Left = (Screen.Height + Left) / 11
Top = (Screen.Width + Top) / 10
Left = (Screen.Height + Left) / 9
Top = (Screen.Width + Top) / 8
Left = (Screen.Height + Left) / 7
Top = (Screen.Width + Top) / 6
Left = (Screen.Height + Left) / 5
Top = (Screen.Width + Top) / 4
Left = (Screen.Height + Left) / 3
Top = (Screen.Width + Top) / 2
Left = (Screen.Height + Left) / 1


Form1.Show

End Sub

String Tokenizer Similar To strtok() in C++

Diposting oleh Source Code Program | 20.34 | | 0 komentar »

//Declare private string for the unit
implementation
var

TokS: string


//Function To Get Characters From The String function StrMid(const sData: string; nStart: integer; nLength: integer): string; overload;
begin

Result := copy(sData, nStart, nLength);

end;

//Function To Get Characters From The String function StrMid(const sData: string; nStart: integer): string; overload;
begin

Result := copy(sData, nStart, Length(sData) - (nStart - 1));

end;

//String Tokenizer function
function StrTok(S: string; Tok: string = ''): string;
var

i,
LenTok: integer;

begin

if not(S = '') then begin //New String

TokS := S;
result := '';
Exit;

end;

if Tok = '' then begin //If No Token

result := TokS;
Exit;

end;

LenTok := Length(Tok);
for i := 0 to Length(TokS) - LenTok do begin

if StrMid(TokS, i, LenTok) = Tok then begin //If Token Found

result := StrMid(TokS, 1, i - LenTok);
TokS := StrMid(TokS, i + LenTok + 1);
Exit;

end;

end;

//If Program Reaches Here, Return The Rest Of The String
result := TokS;
TokS := '';

end;


Therefore, for example, if you defined a string:
var

S: string


and set S to 'Hello World'

S := 'Hello World';


and then call StrTok() like so:

StrTok(S);

The procedure will store the string, from now on, calling StrTok() with no S value and a token (such as a space ' '), the program will return everything in the string up to the token.

EX:
var

firstWord,
secondWord: string


begin

StrTok(S);
firstWord := StrTok('', ' ');
secondWord := StrTok('', ' ');

end;

//Doing this will break apart the string S at the token (' ') into the first word and the second word.

A form of delay

Diposting oleh Source Code Program | 20.17 | | 0 komentar »

procedure Delay(ms : longint);
var
TheTime : LongInt;
begin
TheTime := GetTickCount + ms;
while GetTickCount < TheTime do Application.ProcessMessages;
end;