473,395 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to fix error: EXPECTED: END STATEMENT? frmframe is highlighted in this code

Expand|Select|Wrap|Line Numbers
  1. Public Class frmMain
  2.  
  3. Private Sub btnCalulate_Click(ByVal sender As System.Object, ByVal e As
  4.  
  5. System.EventArgs) Handles btnCalulate.Click
  6.  
  7. Try
  8. Dim LoanAmount As Double
  9.  
  10. Dim Payment As DoubleDim
  11. InterestRate As Double
  12.  
  13. Dim Interest As DoubleDim
  14. Principle As Double
  15.  
  16. Dim Years As IntegerDim
  17. PaymentPeriods As Integer
  18.  
  19. Dim LoanOptionSelection As Integer
  20.  
  21.  
  22.  
  23. 'setup loan options array with values
  24.  
  25. Dim LoanOptions(3, 2) As Double
  26.  
  27. LoanOptions(0, 0) = 7
  28.  
  29. LoanOptions(0, 1) = 5.35
  30.  
  31. LoanOptions(1, 0) = 15
  32.  
  33. LoanOptions(1, 1) = 5.5
  34.  
  35. LoanOptions(2, 0) = 30
  36.  
  37. LoanOptions(2, 1) = 5.75
  38.  
  39.  
  40.  
  41. 'validate loan amount input
  42.  
  43. If IsNumeric(txtLoanAmount.Text) = False Then
  44. MsgBox("Loan amount must be numeric. Please enter a validloan amount.")
  45.  
  46. txtLoanAmount.Clear()
  47.  
  48. txtLoanAmount.Focus()
  49.  
  50. Exit Sub
  51.  
  52. End If
  53.  
  54.  
  55.  
  56. 'set loan variables
  57.  
  58. LoanAmount = txtLoanAmount.Text
  59.  
  60.  
  61.  
  62. 'set proper rate and years depending on option selected by user
  63.  
  64. Select Case True
  65. Case optLoanOption1.Checked
  66.  
  67. LoanOptionSelection = 0
  68. Case optLoanOption2.Checked
  69.  
  70. LoanOptionSelection = 1
  71. Case optLoanOption3.Checked
  72.  
  73. LoanOptionSelection = 2
  74.  
  75. End Select
  76.  
  77.  
  78.  
  79. 'using array and loan option set the rate and years
  80.  
  81. InterestRate = LoanOptions(LoanOptionSelection, 1)
  82.  
  83. Years = LoanOptions(LoanOptionSelection, 0)
  84.  
  85.  
  86.  
  87. 'calulate total payment periods
  88.  
  89. PaymentPeriods = Years * 12
  90.  
  91.  
  92.  
  93. 'if rate is in percent form convert to decimal
  94.  
  95. If InterestRate > 1 Then InterestRate = InterestRate / 100
  96.  
  97.  
  98.  
  99. 'calculate monthly payment and return value
  100.  
  101. Payment = (LoanAmount * Math.Pow((InterestRate / 12) + 1,
  102.  
  103. (PaymentPeriods)) * InterestRate / 12) / (Math.Pow(InterestRate / 12 + 1,
  104.  
  105. (PaymentPeriods)) - 1)
  106.  
  107.  
  108.  
  109. 'display calculated payment
  110. lblMonthlyPayment.Text = "Monthly Payment: " &
  111.  
  112. FormatCurrency(Payment)
  113.  
  114.  
  115.  
  116. 'clear datagrid view control (remove all rows)
  117.  
  118. dgvLoanDetails.Rows.Clear()
  119.  
  120.  
  121.  
  122. 'setup progress bar
  123.  
  124. pbLoan.Minimum = 1
  125.  
  126. pbLoan.Maximum = PaymentPeriods
  127.  
  128. pbLoan.Value = 1
  129.  
  130. pbLoan.Visible = True
  131.  
  132.  
  133.  
  134. 'loop the loan payment periods displaying loan details
  135. Dim i As Integer
  136.  
  137. For i = 1 To PaymentPeriods
  138.  
  139.  
  140.  
  141. 'increase progress bar
  142.  
  143. pbLoan.Value = i
  144.  
  145.  
  146.  
  147. 'set interest
  148.  
  149. Interest = (LoanAmount * InterestRate) / 12
  150.  
  151.  
  152.  
  153. 'set loan amount
  154.  
  155. LoanAmount = (LoanAmount - Payment) + Interest
  156.  
  157.  
  158.  
  159. 'set principle
  160.  
  161. Principle = Payment - Interest
  162.  
  163.  
  164.  
  165. 'output loan details
  166.  
  167. dgvLoanDetails.Rows.Add()
  168. dgvLoanDetails.Item("Month", i - 1).Value = idgvLoanDetails.Item("Payment", i - 1).Value =
  169.  
  170. FormatCurrency(Payment)
  171. dgvLoanDetails.Item("Interest", i - 1).Value =
  172.  
  173. FormatCurrency(Interest)
  174. dgvLoanDetails.Item("Principle", i - 1).Value =
  175.  
  176. FormatCurrency(Principle)
  177. dgvLoanDetails.Item("LoanAmount", i - 1).Value =
  178.  
  179. FormatCurrency(LoanAmount)
  180.  
  181. Next
  182.  
  183.  
  184.  
  185. 'hide progress bar now that processing is completed
  186. pbLoan.Visible = False Catch ex As Exception
  187.  
  188. MsgBox("Error: " & ex.Message.ToString())
  189.  
  190. End Try
  191.  
  192. End Sub
  193.  
  194. Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As
  195.  
  196. System.EventArgs) Handles btnClear.Click
  197.  
  198.  
  199.  
  200. 'clear fields
  201.  
  202. txtLoanAmount.Clear()
  203.  
  204. optLoanOption1.Checked = True
  205.  
  206. lblMonthlyPayment.Text = ""
  207.  
  208. txtLoanAmount.Text = "200000"
  209.  
  210. dgvLoanDetails.Rows.Clear()
  211.  
  212. End Sub
  213.  
  214. Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
  215.  
  216. System.EventArgs) Handles btnExit.Click
  217.  
  218.  
  219.  
  220. 'end program
  221.  
  222. End
  223.  
  224. End Sub
  225.  
  226. End Class
I WOULD LIKE IT TO WORK IN EXCEL
Nov 12 '10 #1
1 1945
Stewart Ross
2,545 Expert Mod 2GB
If you want to write code for running in Excel you will need to use Visual Basic for Applications (VBA), not VB itself. Excel will not understand the VB code as you have written it.

-Stewart
Nov 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Raphael Gluck | last post by:
Hi I've been trying to hand code my pages, after failing in a WSYWYG editor and giving up. I'm almost done with the page checking, it's just i'm having a Wend error Microsoft VBScript...
3
by: Matt | last post by:
When the ASP statement end with a _ character, then the next line cannot have comment ' character. Is that correct? Since I encountered the following error: Microsoft VBScript compilation...
5
by: andy.herrera | last post by:
I'm getting this Error Message. Expected ';' Please Select One: <form name="form1"> <<------------ Error is here. <select name="selectTrans" onChange="If (this.value == 'checkout')...
2
by: Layla | last post by:
I thought this was ok.... but... I get the following message: COMPILE ERROR- EXPECTED END OF STATEMENT and the "Where" is highlighted. I'm a bit of a novice at this so any help at all would be much...
3
by: wwwursa | last post by:
I am trying to use the Right function in a VB6 program. I have used it used many times before in other programs. When I press the enter key after entering the code line, the word "Right" turns...
5
by: amitmool | last post by:
hi, i have used the queue library file and try to use the template as template <class QueueItem> queue <QueueItem>::~queue() // line 25 { } template <class QueueItem> void...
3
by: Indy | last post by:
Hi, I am new to VB and have some previous programming experiences. Curently working as an IT support person and trying to write a VB 6 script to access apos database and get one of the table's...
2
by: noemailplease0001 | last post by:
#ifndef POSITION_H_ #define POSITION_H_ class Position { public: Position(std::string name, std::string name): m_name( name), m_description(description){} std::string toString(); private:
2
by: prw8864 | last post by:
I can not see what is causing this error.... iterator has been defined properly, but the error seems to point to the interator type. Errors I get with g++ svector.c++ -o svector 2> ./err_txt...
1
by: rameshjumgam | last post by:
i am having in my code like std::list<T*>::const_iterator iter=lst.begin(); and i am getting error error: expected `;' before âiterâ /root/INCLUDE/cw/gdlist.h:140: error: âiterâ was...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.