Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > I have difficulties with this problem


Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2002, 08:15 AM
justin_phung
Guest
 
Posts: n/a
Question I need help with this program I'm trying to do


i am doing this program which uses other subprograms to function but somewhere in it there's mistake so i just get run-time errors all the time........
can u please have a look and spot out the mistake for me? thank you

the code is below...;

just copy into the VB program and run it.............
Code:
Option Explicit

Private Sub Command1_Click()
Dim duration As Integer
Dim power As Double

duration = Text1.Text

If duration > 0 Then
    power = expm() ^ duration
    Label4.Caption = "Power is : " & power
Else
    MsgBox "Months are invalid, please enter again"
    Text2.Text = ""
End If
End Sub

Function expm() As Double
expm = 1 + ratem()
Label3.Caption = "Expm is : " & expm
End Function

Function ratem() As Double
Dim rate As Single

rate = Text1.Text

If rate > 0 Then
    ratem = rate / 1200
    Label2.Caption = "Ratem is : " & ratem
Else
    MsgBox "The interest rate is invalid.  Please enter a valid interest rate"
    Text1.Text = ""
End If
End Function

Private Sub Form_Load()
Label1.Caption = "Enter Interest Rate :"
Label2.Caption = "Ratem is : "
Label3.Caption = "Expm is : "
Label4.Caption = "Power is : "
Label5.Caption = "Enter Number Of Months :"
Command1.Caption = "Calculate"
Text1.Text = ""
Text2.Text = ""
End Sub
the program interface you can open the file and see it......

Last edited by Thinker; 07-12-2002 at 12:34 PM.
Reply With Quote
  #2  
Old 07-12-2002, 09:22 AM
Bucky's Avatar
Bucky Bucky is offline
A+ Certified Nerd

Retired Leader
* Expert *
 
Join Date: Dec 2001
Location: East Coast
Posts: 1,763
Post

Could you point out some lines that you get errors on? Because I couldn't raise any with normal operation.
However, if you type in anything other than a number in Text1, an error raises because it's trying to set it to a number variable. Use the IsNumeric() function to determine if the input is a number, and alert the user if it isn't.

Also iit seemed that Text2 had no effect on anything.
__________________
If you're not part of the solution, you're part of the precipitate.
Reply With Quote
  #3  
Old 07-12-2002, 10:00 AM
John's Avatar
John John is offline
Bit Flipper
 
Join Date: Feb 2002
Location: The Inner Loop
Posts: 5,550
Default

Just to add to the things Bucky said, please don't attach .exe files. Most of us will not run them for reasons I'm sure you can think of.

If you would like we can look at the whole project if you zip all the required files such as *.frm, *.frx, *.vbp, *.bas, *.cls etc... and attach that zip file instead of a zipped .exe.

Orbity
__________________
Subclassing|Magnetic Forms|Operator Overloading (VB2K5)|QuickSnip.NET

"These Patriot playoff wins are like Ray Charles songs, Nantucket sunsets, and hot fudge sundaes. Each one is better than the last." - Dan Shaughnessy
Reply With Quote
  #4  
Old 07-13-2002, 01:45 AM
justin_phung
Guest
 
Posts: n/a
Default

i just want to say thank you for your response in my problem, the thing is i have a project which i hav to design a program to calculate monthly fee based on some loan, months and interest rate........i was given the formula to work out but i don't know how to code it .......i tried to use subprogram like u have always seen but it doesn't work...........can u help me?
Reply With Quote
  #5  
Old 07-13-2002, 04:03 AM
justin_phung
Guest
 
Posts: n/a
Question I have difficulties with this problem

this problem is related to the ones i asked you guys before and i want to say thank on trying to help me on it..........but since you want me to send the whole file then i sent it here......just download it and please help me thank you
Attached Files
File Type: zip problem.zip (2.9 KB, 4 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->