1 definition by too good for a name

A powerful RAD (rapid application development) progamming language that allows for easy creation of windows programs. Its main flaw is the fact that micro$hit made it, and therefore under their monopoly, it only runs on windows. Another complaint is about the way many new users use the language. They just paste a couple of objects on a form, user a few undeclared variables (variants, which are slow), and run the program. A real program creates objects at runtime and user delared variables at all times (forced by Option Explicit.) Other than that, it is a good language. It is easy enough to learn for beginners (unlike other languages such as java/C++) and powerful enough to perform complicated calculations and make windows-based programs and games with readable code.
'This is a sample VB program
'It finds the prime factors of any number the user specifies
'Declare Objects
Dim WithEvents txtNumber As TextBox
Dim WithEvents lblPrime As Label
Dim WithEvents cmdFactor As CommandButton

Private Sub cmdFactor_Click()
Dim counter&, answer$, number&
'Check to make sure user entered a valid number
If Not IsNumeric(txtNumber) Then Exit Sub
If Len(txtNumber) = 0 Or txtNumber > 2000000000 Or Sgn(txtNumber) = -1 Then Exit Sub
'Create variable = to what user entered.
number = txtNumber
'factor out 2's
Do While number Mod 2 = 0
number = number / 2
answer = answer & " * 2"
Loop
'factor out other numbers
For counter = 3 To number Step 2
Do While number Mod counter = 0
'exit when primes are exhausted
If number = 1 Then Exit Do
number = number / counter
answer = answer & " * " & counter
Loop
Next counter
'results
MsgBox Right$(answer, Len(answer) - 3), 15, "The Prime Factors of " & txtNumber & " are..."
'gives the textbox focus
txtNumber.SetFocus
End Sub

Private Sub Form_KeyDown(KeyCode%, Shift%)
'pressing escape exits the program
If KeyCode = 27 Then Unload Me
End Sub

Private Sub Form_Load()
'set up form
With Me
.KeyPreview = True
.Move (Screen.Width - .Width) \ 2, (Screen.Height - .Width) \ 2
End With
Set txtNumber = Controls.Add("VB.TextBox", "txtNumber")
With txtNumber
.Move (Me.Width - .Width) \ 2, (Me.Height - .Width) \ 2
.Visible = True
End With
Set lblPrime = Controls.Add("VB.Label", "lblPrime")
With lblPrime
.Caption = "Find Prime Factors Of What Number?"
.Move txtNumber.Left, txtNumber.Top - 800, .Width, .Height + 400
.Visible = True
End With
Set cmdFactor = Controls.Add("VB.CommandButton", "cmdFactor")
With cmdFactor
.Caption = "Factor"
.Default = True
.Move txtNumber.Left, txtNumber.Top + 800
.Visible = True
End With
End Sub

Private Sub Form_Terminate()
'clean up
Dim clrObject As Object
For Each clrObject In Me
clrObject = ""
Next clrObject
End
End Sub
by too good for a name December 6, 2004
Get the Visual Basic mug.