# vbNewline doesn't work

Page 1 of 1

## 2 Replies - 1898 Views - Last Post: 16 December 2011 - 09:12 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=260175&amp;s=4d95727b853251ac5b58e3b278dcb553&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

Reputation: 31
• Posts: 139
• Joined: 01-October 10

# vbNewline doesn't work

Posted 16 December 2011 - 08:04 PM

Peace be upon you and good morning. I was trying to make a PTPTN loan calculator that calculate the required monthly payment accordingly. But when I tried to print into the text box, it only exist for a line. The vbNewLine or vbcrlf didn't seems to work. The following is my code. Is there any limitation in using vbNewline that I need to know? I also accept any other suggestion or advice regarding my code as I am still learning.

```'PTPTN
'Calculate the amount that a student must pay every month to pay for their PTPTN study loan.
' Look for:
' 1. PTPTN interest rate = 1% per annum
' 2. Principle = RM 12,500
' 3. Years to pay < 10 years
'E.g.:
'Year  | Monthly Payment(RM) | Balance Payment(RM)
' 1    |                     |     12625
' 2
' Expected to have looping to display part.
'Formula :
'interest = principle * interestRate/100
'yearlyPayment = principle / yearsToPay
'monthlyPayment = (yearlyPayment + interest)/12
'totalPayment = totalPayment yearlyPayment
Option Explicit
Dim interest, interestRate, totalPayment, principle, yearlyPayment, monthlyPayment As Double
Dim yearsToPay, yearCounter As Integer
Dim stringCounter As String
Const monthPerYear As Integer = 12

Private Sub cmdCalculate_Click()
interestRate = txtInterestRate.Text
principle = txtTotalLoan.Text
yearsToPay = txtYears2Pay.Text
On Error GoTo errorLabel1 'errorchecking
totalPayment = principle
yearlyPayment = principle / yearsToPay

interest = interestRate / 100 * principle

stringCounter = "Year" & vbTab & "Monthly Payment(RM)" & vbTab & "Balance Payment(RM)"
stringCounter = stringCounter & vbNewLine

For yearCounter = 1 To 10
monthlyPayment = (yearlyPayment + interest) / monthPerYear
totalPayment = totalPayment - yearlyPayment
stringCounter = stringCounter & yearCounter & vbTab & monthlyPayment & vbTab & totalPayment & vbNewLine
Next
txtDisplay.Text = stringCounter
txtTotalLoan.Enabled = False
txtYears2Pay.Enabled = False
cmdCalculate.Enabled = False
txtDisplay.Enabled = True
Exit Sub
errorLabel1: 'end when have error
End Sub

Private Sub cmdClear_Click()
interest = interestRate = totalPayment = principle = yearlyPayment = monthlyPayment = yearsToPay = 0
txtYears2Pay.Text = "0"
txtTotalLoan.Text = "0"
txtDisplay.Text = ""
txtTotalLoan.Enabled = True
txtYears2Pay.Enabled = True
cmdCalculate.Enabled = True
txtDisplay.Enabled = False
MsgBox "Cleared!"
End Sub

Private Sub cmdExit_Click()
MsgBox "Have a great day! ^_^/>"
End
End Sub

MsgBox "Hello! :)/>"
End Sub

```

Is This A Good Question/Topic? 0

## Replies To: vbNewline doesn't work

### #2 GunnerInc

• "Hurry up and wait"

Reputation: 902
• Posts: 2,349
• Joined: 28-March 11

## Re: vbNewline doesn't work

Posted 16 December 2011 - 08:08 PM

Edit Controls (Text Boxes) are single line by default. You have to change it to multiline for carriage returns to show multiple lines. Click on your text box, and somewhere in the properties list change multi line to true.

Reputation: 31
• Posts: 139
• Joined: 01-October 10

## Re: vbNewline doesn't work

Posted 16 December 2011 - 09:12 PM

Ah, you're right. Thank you.