[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problems upgarding a program I  made from VB.net 2003 to Vb.net 2005 express

Posted on 2006-03-28
4
Medium Priority
?
219 Views
Last Modified: 2010-04-23
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??????
0
Comment
Question by:ucla12
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 16317598
none of the variables in SimpFraction1 are declared.

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
0
 
LVL 14

Accepted Solution

by:
amyhxu earned 2000 total points
ID: 16317925
I'm not sure if the following function will make the error message away. But your old code is obviously not written in the .NET way. It could be those line numbers and GOTOs that's causing the problem. I've modified it to make it look a little better:

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
0
 
LVL 21

Expert Comment

by:oleggold
ID: 16318964
This seems exactly the answer to Your question:
http://www.codeproject.com/vb/net/
0
 
LVL 21

Expert Comment

by:oleggold
ID: 16319018
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question