I made a program a while back in vb.net, A fraction calculator, a long the way the form file for this project was lost when I had problems with a hard drive. I still had all the code so I decided to copy and paste the code into a new vb.net 2005 express project. I rerembered what the old form looked like, so I recreated it from scratch and renamed all the controls to match the code. Every thing should have worked, so I thought. When I try to run (bulild the program I get error messages saying variables are not declared. I copied all of the variables and placed them in the declarations. example (Public intNum1 As Integer) I then move them the calculate button click event and changed them from Public to Dim as . Well this seemed to work as far as not saying they are not declared. I created several Sub Procedures to do things like simplifing fractions, finding GCF ect. when you press the calculate button it call these procedures get an anwser. Now it is saying GFC () name is not declare, that is the procedure to fing the Greatest common factor and all the procedures are reconizied(they say they are not declared)

Public Function GCF(ByVal int1 As Single, ByVal int2 As Single) As Single

'Finds the greatest common factor of two integers

Dim r As Single

Dim x As Single

If int1 < 0 Then int1 = System.Math.Abs(int1)

If int2 < 0 Then int2 = System.Math.Abs(int2)

If int1 = int2 Then GCF = int1 : Exit Function

If int1 < int2 Then

x = int2

int2 = int1

int1 = x

End If

20: r = int1 Mod int2

If r = 0 Then GoTo 50

40: int1 = int2 : int2 = r : GoTo 20

50: GCF = int2

End Function

I just wanted to show you what a sample of the code looked like, the others are procedures.....

these one will simplify Fracton 1

Public Sub SimpFraction1()

'simplify fraction 1

intNum1 = CInt(txtNum1.Text)

intDen1 = CInt(txtDen1.Text)

intMix1 = CInt(txtMix1.Text)

intTemp4 = GCF(intNum1, intDen1)

intNum1 = intNum1 / intTemp4

intDen1 = intDen1 / intTemp4

txtNum1.Text = intNum1

txtDen1.Text = intDen1

End Sub

All these work find in VB.net 2003 It appears the coding is the same for 2003 and 2005

How come I am getting these messages??????

Public Function GCF(ByVal int1 As Single, ByVal int2 As Single) As Single

'Finds the greatest common factor of two integers

Dim r As Single

Dim x As Single

If int1 < 0 Then int1 = System.Math.Abs(int1)

If int2 < 0 Then int2 = System.Math.Abs(int2)

If int1 = int2 Then GCF = int1 : Exit Function

If int1 < int2 Then

x = int2

int2 = int1

int1 = x

End If

20: r = int1 Mod int2

If r = 0 Then GoTo 50

40: int1 = int2 : int2 = r : GoTo 20

50: GCF = int2

End Function

I just wanted to show you what a sample of the code looked like, the others are procedures.....

these one will simplify Fracton 1

Public Sub SimpFraction1()

'simplify fraction 1

intNum1 = CInt(txtNum1.Text)

intDen1 = CInt(txtDen1.Text)

intMix1 = CInt(txtMix1.Text)

intTemp4 = GCF(intNum1, intDen1)

intNum1 = intNum1 / intTemp4

intDen1 = intDen1 / intTemp4

txtNum1.Text = intNum1

txtDen1.Text = intDen1

End Sub

All these work find in VB.net 2003 It appears the coding is the same for 2003 and 2005

How come I am getting these messages??????

Public Sub SimpFraction1()

'simplify fraction 1

dim intNum1, intDen1, intMix1, intTemp4 as integer

intNum1 = CInt(txtNum1.Text)

intDen1 = CInt(txtDen1.Text)

intMix1 = CInt(txtMix1.Text)

intTemp4 = GCF(intNum1, intDen1)

intNum1 = intNum1 / intTemp4

intDen1 = intDen1 / intTemp4

txtNum1.Text = intNum1

txtDen1.Text = intDen1

End Sub

This seems exactly the answer to Your question:

http://www.codeproject.com/vb/net/

http://www.codeproject.com/vb/net/

Sorry,this one:

http://www.codeproject.com/vb/net/FirstLookVBExpress.asp

http://www.codeproject.com/vb/net/FirstLookVBExpress.asp

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

Public Function GCF(ByVal int1 As Single, ByVal int2 As Single) As Single

'Finds the greatest common factor of two integers

Dim r As Single

Dim x As Single

If int1 < 0 Then int1 = System.Math.Abs(int1)

If int2 < 0 Then int2 = System.Math.Abs(int2)

If int1 = int2 Then Return int1

If int1 < int2 Then

x = int2

int2 = int1

int1 = x

End If

r = int1 Mod int2

Do While r > 0

int1 = int2

int2 = r

r = int1 Mod int2

Loop

Return int2

End Function