String Concatenation in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kellysgirl
    New Member
    • Mar 2007
    • 9

    String Concatenation in VB

    Code:
    Option Explicit On
    Option Strict On
    
    Imports System.Globalization
    
    Public Class MainForm
    
        Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
            Me.Close()
        End Sub
    
        Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            ' fills the combo box with values, then selects the first value
    
            For years As Integer = 3 To 20
                lifeComboBox.Items.Add(years.ToString)
            Next years
            lifeComboBox.SelectedIndex = 0
        End Sub
    
        [B]Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click
            ' displays a double-declining balance depreciation schedule
    
            Dim cost As Double
            Dim life As Double
            Dim period As Double
            Dim salvage As Double
            Dim depreciation As Double
            Dim isConvertedCost As Boolean
            Dim isConvertedLife As Boolean
            Dim isConvertedSalvage As Boolean
    
            isConvertedCost = Double.TryParse(costTextBox.Text, _
                NumberStyles.Currency, NumberFormatInfo.CurrentInfo, cost)
            isConvertedLife = Double.TryParse(lifeComboBox.Text, life)
            isConvertedSalvage = Double.TryParse(salvageTextBox.Text, _
                NumberStyles.Currency, NumberFormatInfo.CurrentInfo, salvage)
    
            If isConvertedCost AndAlso isConvertedLife AndAlso isConvertedSalvage Then
                scheduleTextBox.Text = "     Year     Depreciation"
    
                ' 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.
    
    
    
    
            Else
                MessageBox.Show("The cost, life, and salvage values must be numeric.", _
                    "Sonheim Manufacturing Company", MessageBoxButtons.OK, _
                    MessageBoxIcon.Information)
            End If[/B]        costTextBox.Focus()
        End Sub
    
       
        Private Sub costTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles costTextBox.Enter
            costTextBox.SelectAll()
        End Sub
    
        Private Sub costTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles costTextBox.TextChanged
            scheduleTextBox.Clear()
        End Sub
    
        Private Sub lifeComboBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lifeComboBox.TextChanged
            scheduleTextBox.Clear()
        End Sub
    
        Private Sub salvageTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles salvageTextBox.Enter
            salvageTextBox.SelectAll()
        End Sub
    
        Private Sub salvageTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles salvageTextBox.TextChanged
            scheduleTextBox.Clear()
        End Sub
    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
    Last edited by Killer42; Mar 29 '07, 08:10 AM. Reason: Please use [CODE]...[/CODE] tags around your code.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    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.

    Comment

    • vijaydiwakar
      Contributor
      • Feb 2007
      • 579

      #3
      just point and explain the error area
      rather than giving a complete code

      Comment

      • kellysgirl
        New Member
        • Mar 2007
        • 9

        #4
        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

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by kellysgirl
          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...
          Originally posted by 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

          Comment

          • kellysgirl
            New Member
            • Mar 2007
            • 9

            #6
            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.

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by kellysgirl
              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.

              Comment

              Working...