|
-
Apr 12th, 2008, 05:28 PM
#1
Thread Starter
Member
[RESOLVED] Type 'label', 'textBox', 'button' is not defined
I am a beginner at Visual Basic and Im using the following to help me learn:
1. Visual Basic 2005 Express Edition;
2. Deitel's Visual Basic.NET second edition; and
3. Learn Visual Studios videos .
I keep getting the following errors when I try to run a class from Deitel's book (see below) :
Type 'label' is not defined
Type 'textBox' is not defined
Type 'button' is not defined
I have 3 questions:
1. How do I run a class? The code below has no main and Visual 2005 does not 'generate' any additional code for me.
2. Which references do I have to add to get rid of the above mentioned error messages? And why should I have to constantly be adding these references when I think Visual 2005 should automatically do this for me?
3. I save this project as a Class cause it did not work as a Windows project. Was this correct?
Any assistance will be appreciated. Thank you in advance.
Code:
' Fig. 6.19: Factorial.vb
' Calculating factorials using recursion
Public Class Class1
Inherits System.Windows.Forms.Form
Friend WithEvents lblEnter As label ' intellisence does not recognize Label
Friend WithEvents lblFactorial As label ' intellisence does not recognize Label
Friend WithEvents txtInput As TextBox 'intellisence does not recognize TextBox
Friend WithEvents txtDisplay As textBox 'intellisence does not recognize TextBox
Friend WithEvents cmdCalculate As Button ' intellisence does not recognize Button
' Visual Studio .NET generated code (Visual Basic 2005 does not generate any code)
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click
Dim value As Integer = Convert.ToInt32(txtInput.text)
Dim i As Integer
Dim output As String
txtDisplay.Text = ""
For i = 0 To value
txtDisplay.Text &= i & "! = " & Factorial(i) & vbCrLf
Next
End Sub ' cmdCalculate_Click
' recursively generates factorial of number
Function Factorial(ByVal number As Long) As Long
If number <= 1 Then
Return 1
Else
Return number * Factorial(number - 1)
End If
End Function
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|