473,395 Members | 1,442 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.

String Concatenation in VB

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
6 5191
Killer42
8,435 Expert 8TB
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
579 512MB
just point and explain the error area
rather than giving a complete code
Mar 29 '07 #3
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
Killer42
8,435 Expert 8TB
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
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
Killer42
8,435 Expert 8TB
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

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

Similar topics

5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
20
by: hagai26 | last post by:
I am looking for the best and efficient way to replace the first word in a str, like this: "aa to become" -> "/aa/ to become" I know I can use spilt and than join them but I can also use regular...
3
by: John Ford | last post by:
For simple string concatenation, is there a difference between... Dim s As String s += "add this to string" ....and... Dim s As String s = String.Concat(s, "add this to string")
9
by: Justin M. Keyes | last post by:
Hi, Please read carefully before assuming that this is the same old question about string concatenation in C#! It is well-known that the following concatenation produces multiple immutable...
16
by: Mark A. Sam | last post by:
Hello, I am having a problem with imputting into a string variable: Dim strSQL As String = "INSERT INTO tblContactForm1 (txtName, txtCompany, txtPhone, txtEmail, txtComment, chkGrower,...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
12
by: Richard Lewis Haggard | last post by:
I thought that the whole point of StringBuilder was that it was supposed to be a faster way of building strings than string. However, I just put together a simple little application to do a...
34
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
10
by: =?Utf-8?B?RWxlbmE=?= | last post by:
I am surprised to discover that c# automatically converts an integer to a string when concatenating with the "+" operator. I thought c# was supposed to be very strict about types. Doesn't it seem...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.