Private b1() As Byte
Private b2() As Byte
Public Function Simil(String1 As String, String2 As String) As Double
Dim l1 As Long
Dim l2 As Long
Dim l As Long
Dim r As Double
If UCase(String1) = UCase(String2) Then
r = 1
Else
l1 = Len(String1)
l2 = Len(String2)
If l1 = 0 Or l2 = 0 Then
r = 0
Else
ReDim b1(1 To l1): ReDim b2(1 To l2)
For l = 1 To l1
b1(l) = Asc(UCase(Mid(String1, l, 1)))
Next
For l = 1 To l2
b2(l) = Asc(UCase(Mid(String2, l, 1)))
Next
r = SubSim(1, l1, 1, l2) / (l1 + l2) * 2
End If
End If
Simil = r
Erase b1
Erase b2
End Function
Private Function SubSim(st1 As Long, end1 As Long, st2 As Long, end2 As Long) As Long
Dim c1 As Long
Dim c2 As Long
Dim ns1 As Long
Dim ns2 As Long
Dim i As Long
Dim max As Long
If st1 > end1 Or st2 > end2 Or st1 <= 0 Or st2 <= 0 Then Exit Function
For c1 = st1 To end1
For c2 = st2 To end2
i = 0
Do Until b1(c1 + i) <> b2(c2 + i)
i = i + 1
If i > max Then
ns1 = c1
ns2 = c2
max = i
End If
If c1 + i > end1 Or c2 + i > end2 Then Exit Do
Loop
Next
Next
max = max + SubSim(ns1 + max, end1, ns2 + max, end2)
max = max + SubSim(st1, ns1 - 1, st2, ns2 - 1)
SubSim = max
End Function
Public Function screenWipe(Form As Form, CutSpeed As Integer) As Boolean
Dim OldWidth As Integer
Dim OldHeight As Integer
Form.WindowState = 0
If CutSpeed <= 0 Then
MsgBox "You cannot use 0 as a speed value"
Exit Function
End If
Do
OldWidth = Form.Width
Form.Width = Form.Width - CutSpeed
DoEvents
If Form.Width <> OldWidth Then
Form.Left = Form.Left + CutSpeed / 2
DoEvents
End If
OldHeight = Form.Height
Form.Height = Form.Height - CutSpeed
DoEvents
If Form.Height <> OldHeight Then
Form.Top = Form.Top + CutSpeed / 2
DoEvents
End If
Loop While Form.Width <> OldWidth Or Form.Height <> OldHeight
Unload Form
End Function
Randomize Three Intro Art Splash Screen's Load
Diposting oleh Source Code Program | 02.23 | visual basic | 0 komentar »Private Sub Form_Load()
'main is the form that shows up after th
' e intro art, could be form1, main or wha
' tever you call it.
'main.visible=false , that hides the ori
' ginal form
Main.Visible = False
'makes the following coding randomized
Randomize
'lets it know there will be three option
' s
Select Case Int((Rnd * 3) + 1)
'if case 1 is selected then the intro1 f
' orm loads
Case 1
intro1.Visible = True
'if case 2 is selected then the intro2 f
' orm loads
Case 2
intro2.Visible = True
'if case 3 is selected then the intro3 f
' orm loads
Case 3
intro3.Visible = True
'ends it
End Select
'*******END CODING*********
'inside intro1,2,3, you should have eith
' er a timer and after an alloted time it
' makes main.visible=true, and/or on Mouse
' Click of the picture itself. so heres an
' d example
'Intro1
'if someone clicks on the intro picture
' on intro1
'Private Sub Picture_click()
'hides the intro
'intro1.visible=false
'shows main iface
'main.visible=true
'End Sub
Scrolling text visual basic
Diposting oleh Source Code Program | 02.17 | visual basic | 0 komentar »VERSION 5.00
Begin VB.Form Form1
BackColor=&H80000007&
Caption ="(c)1999 Mr Slade, please visit me at http://hem.passagen.se/tonek/vb"
ClientHeight=2205
ClientLeft =60
ClientTop=345
ClientWidth =6120
ControlBox =0'False
LinkTopic="Form1"
ScaleHeight =2205
ScaleWidth =6120
StartUpPosition =3 'Windows Default
Begin VB.Timer Timer1
Interval=500
Left=0
Top =0
End
Begin VB.Label Label1
Alignment=1 'Right Justify
BackStyle=0 'Transparent
BeginProperty Font
Name="Garamond"
Size=11.25
Charset =0
Weight =400
Underline=0'False
Italic =0'False
Strikethrough=0'False
EndProperty
ForeColor=&H0080C0FF&
Height =255
Left=840
TabIndex=0
Top =840
Width=4335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'// Let you make scrollable text in a la
' bel without moving the label.. its fixed
' ...
'// ----------------
'// Got it from: http://hem.passagen.se/
' tonek/vb
'// Author : Martin Tonek
'// Date of upload : July/15/1999
'// ----------------
'// Remember that this code only functio
' n with the assigned fonts,fontssize and
'// labelwidth. It will look more nicer
' when using ths font that have a fixed
'// width then a font like arial. Also t
' he labelwidth was set for 41 letters so
'// when changing the font you have to c
' hange labelwidth or/and settings for
'// letters.
'//
'// CAUTION!! Change the source code and
' the code can fail!!
'//
'// AddMezz (c)1998 EzySoft, All rights
' reserved
Dim s As Integer
Dim dta As String
Private Sub Form_Load()
'// Centering the form
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
'// Change Label and Timer prefs
Label1.Caption = ""
Timer1.Enabled = True
Timer1.Interval = 100
Label1.Width = 4335
Label1.Font = "Courier New"
Label1.Font.Size = 9
Label1.Font.Bold = True
End Sub
Private Sub Timer1_Timer()
'// put your text here in dta string
dta = "Mr Slade made IT - please visit http://hem.passagen.se/tonek/vb For updates and other avalible sources! (c)1999 Mr Slade" & Space$(41)
s = s + 1
Label1.Caption = Mid(dta, 1, s)
If Len(Label1.Caption) >= 42 Then Label1.Caption = Right(Label1.Caption, 41)
If s = Len(dta) Then
Label1.Caption = ""
s = 0
End If
End Sub
Java Loops (while, do-while and for loops)
Diposting oleh Source Code Program | 02.31 | Java | 0 komentar »For loops typically iterate a fixed number of times and then exit. While loops iterate continuously until a particular condition is met. You usually do not know in advance how many times a while loop will loop.
In this case we want to write a loop that will print each of the command line arguments in succession, starting with the first one. We don't know in advance how many arguments there will be, but we can easily find this out before the loop starts using the args.length. Therefore we will write this with a for loop. Here's the code:
Source Code
// This is the Hello program in Java
class Hello {
public static void main (String args[]) {
int i;
/* Now let's say hello */
System.out.print("Hello ");
for (i=0; i < args.length; i = i++) {
System.out.print(args[i]);
System.out.print(" ");
}
System.out.println();
}
} We begin the code by declaring our variables. In this case we have exactly one variable, the integer i. i Then we begin the program by saying "Hello" just like before.
Next comes the for loop. The loop begins by initializing the counter variable i to be zero. This happens exactly once at the beginning of the loop. Programming tradition that dates back to Fortran insists that loop indices be named i, j, k, l, m and n in that order.
Next is the test condition. In this case we test that i is less than the number of arguments. When i becomes equal to the number of arguments, (args.length) we exit the loop and go to the first statement after the loop's closing brace. You might think that we should test for i being less than or equal to the number of arguments; but remember that we began counting at zero, not one.
Finally we have the increment step, i++ (i=i+1). This is executed at the end of each iteration of the loop. Without this we'd continue to loop forever since i would always be less than args.length.
The Java programming language supports three kinds of comments:
/* text */
The compiler ignores everything from /* to */.
/** documentation */
This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */. The JDK javadoc tool uses doc comments when preparing automatically generated documentation.
// text
The compiler ignores everything from // to the end of the line.
Example
Java denotes comments in three ways:
1. Double slashes in front of a single line comment:
int i=5; // Set the integer to 5
2. Matching slash-asterisk (/*) and asterisk-slash (*/) to bracket multi-line comments:
/*
Set the integer to 5
*/
int i=5;
3. Matching slash-double asterisk (/**) & asterisk-slash(*/) for Javadoc automatic hypertext documentation, as in
/**
This applet tests graphics.
*/
public class testApplet extends applet{...
or
/**
* Asterisks inside the comment are ignored by javadoc so they
* can be used to make nice line markers.
**/
The SDK tool javadoc uses the latter /** ..*/ comment style when it produces hypertext pages to describe a class.
A java program is defined by a public class that takes the form:
public class program-name {
optional variable declarations and methods
public static void main(String[] args) {
statements
}
optional variable declarations and methods
}Source Code
In your favorite editor, create a file called HelloWorld.java with the following contents:
/** Comment
* Displays "Hello World!" to the standard output.
*/
class HelloWorld {
public static void main (String args[]) {
System.out.println("Hello World!"); //Displays the enclosed String on the Screen Console
}
}
To compile Java code, we need to use the 'javac' tool. From a command line, the command to compile this program is:
javac HelloWorld.java
For this to work, the javac must be in your shell's path or you must explicitly specify the path to the program (such as c:\j2se\bin\javac HelloWork.java). If the compilation is successful, javac will quietly end and return you to a command prompt. If you look in the directory, there will now be a HelloWorld.class file. This file is the compiled version of your program. Once your program is in this form, its ready to run. Check to see that a class file has been created. If not, or you receive an error message, check for typographical errors in your source code.
You're ready to run your first Java application. To run the program, you just run it with the java command:
java HelloWorld
Sample Run
Hello world!
HelloWorld.java
Note: It is important to note that you use the full name with extension when compiling (javac HelloWorld.java) but only the class name when running (java HelloWorld).

Development of computer programming accelerated through the Industrial Revolution. The punch card innovation was later refined by Herman Hollerith who, in 1896 founded the Tabulating Machine Company (which became IBM). He invented the Hollerith punched card, the card reader, and the key punch machine. These inventions were the foundation of the modern information processing industry. The addition of a plug-board to his 1906 Type I Tabulator allowed it to do different jobs without having to be physically rebuilt. By the late 1940s there were a variety of plug-board programmable machines, called unit record equipment, to perform data processing tasks (card reading). Early computer programmers used plug-boards for the variety of complex calculations requested of the newly invented machines.
info :http://en.wikipedia.org
