By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,626 Members | 1,424 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,626 IT Pros & Developers. It's quick & easy.

String Concatenation in VB

P: 9
Expand|Select|Wrap|Line Numbers
  1. Option Explicit On
  2. Option Strict On
  3.  
  4. Imports System.Globalization
  5.  
  6. Public Class MainForm
  7.  
  8.     Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
  9.         Me.Close()
  10.     End Sub
  11.  
  12.     Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  13.         ' fills the combo box with values, then selects the first value
  14.  
  15.         For years As Integer = 3 To 20
  16.             lifeComboBox.Items.Add(years.ToString)
  17.         Next years
  18.         lifeComboBox.SelectedIndex = 0
  19.     End Sub
  20.  
  21.     Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click
  22.         ' displays a double-declining balance depreciation schedule
  23.  
  24.         Dim cost As Double
  25.         Dim life As Double
  26.         Dim period As Double
  27.         Dim salvage As Double
  28.         Dim depreciation As Double
  29.         Dim isConvertedCost As Boolean
  30.         Dim isConvertedLife As Boolean
  31.         Dim isConvertedSalvage As Boolean
  32.  
  33.         isConvertedCost = Double.TryParse(costTextBox.Text, _
  34.             NumberStyles.Currency, NumberFormatInfo.CurrentInfo, cost)
  35.         isConvertedLife = Double.TryParse(lifeComboBox.Text, life)
  36.         isConvertedSalvage = Double.TryParse(salvageTextBox.Text, _
  37.             NumberStyles.Currency, NumberFormatInfo.CurrentInfo, salvage)
  38.  
  39.         If isConvertedCost AndAlso isConvertedLife AndAlso isConvertedSalvage Then
  40.             scheduleTextBox.Text = "     Year     Depreciation"
  41.  
  42.             ' write a For .... Next loop here to calculate the double declining balance 
  43.             ' depreciation and use a string concatenation to add the year and depreciation
  44.             ' to the output text box.
  45.  
  46.  
  47.  
  48.  
  49.         Else
  50.             MessageBox.Show("The cost, life, and salvage values must be numeric.", _
  51.                 "Sonheim Manufacturing Company", MessageBoxButtons.OK, _
  52.                 MessageBoxIcon.Information)
  53.         End If        costTextBox.Focus()
  54.     End Sub
  55.  
  56.  
  57.     Private Sub costTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles costTextBox.Enter
  58.         costTextBox.SelectAll()
  59.     End Sub
  60.  
  61.     Private Sub costTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles costTextBox.TextChanged
  62.         scheduleTextBox.Clear()
  63.     End Sub
  64.  
  65.     Private Sub lifeComboBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lifeComboBox.TextChanged
  66.         scheduleTextBox.Clear()
  67.     End Sub
  68.  
  69.     Private Sub salvageTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles salvageTextBox.Enter
  70.         salvageTextBox.SelectAll()
  71.     End Sub
  72.  
  73.     Private Sub salvageTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles salvageTextBox.TextChanged
  74.         scheduleTextBox.Clear()
  75.     End Sub
  76. End Class
Ha ha .....to calculate the double declining balance
' depreciation and use a string concatenation to add the year and depreciation
' to the output text box.


Now I can write a for next statement but with string concatenation how would one do this
Mar 29 '07 #1
Share this Question
Share on Google+
6 Replies


Expert 5K+
P: 8,434
Can you be more specific about exactly what you want help with? Are you simply asking how to concatenate two strings, or what?

Try to keep it brief - most people don't want to read through pages of code to try and find what it is that you want.
Mar 29 '07 #2

vijaydiwakar
100+
P: 579
just point and explain the error area
rather than giving a complete code
Mar 29 '07 #3

P: 9
write a For .... Next loop here to calculate the double declining balance
' depreciation and use a string concatenation to add the year and depreciation
' to the output text box.


This is what I am trying to do but I am not understanding how to do this with string concatenation
Mar 29 '07 #4

Expert 5K+
P: 8,434
write a For .... Next loop here to calculate the double declining balance
' depreciation and use a string concatenation to add the year and depreciation
' to the output text box.


This is what I am trying to do but I am not understanding how to do this with string concatenation
For a start, you cannot use string concatenation to calculate the value. Concatenation is just the action of sticking things together in a string. The idea here is that once you have calculated your depreciation value, you will stick it together with the year. For example:
strSomething = "Year:" & intYear & " Depreciation: $" & curDepreciation

From the sound of the question, I'd recommend you try hard to work your way through this, rather than expecting TheScripts to provide you with a complete program. To quote our policy as described in the FAQ...
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
Mar 29 '07 #5

P: 9
I am not expecting for anyone to supply me with anything. I just wanted some to point me in the right direction. I am new at this but clearly some people on here have forgotten how that feels. That is fine. I have figured it out, thanks.
Mar 30 '07 #6

Expert 5K+
P: 8,434
I am not expecting for anyone to supply me with anything. I just wanted some to point me in the right direction. I am new at this but clearly some people on here have forgotten how that feels. That is fine. I have figured it out, thanks.
No, it's not that we've forgotten. We've just had a lot of trouble with people posting school assignments. We've even had professors in here taking us to task for giving out answers.

And really, if students copy and paste their questions, then copy and paste answers from here, it's not helping anyone. So we have to try to keep this sort of thing under control.
Mar 30 '07 #7

Post your reply

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