Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION
Question and Solution
Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTIONS -- TO SEPARATE COMMA SEPARATE NUMBER VALUES AND THEN SUM T
91 % (888 Review)
Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTIONS -- TO SEPARATE COMMA SEPARATE NUMBER VALUES AND THEN SUM TO TOTAL? I.E., USING SUBSTRING AND INDEXOF. I've been trying to get this to work but am having problems with the loops and counters. Basically -- NOT using arrays or split functions -- I need to write a function that takes one string made of numbers separated by comma and then have the function return the total of all the separate numbers (number of entered comma separated values is fungible depending on how many values the user enters into the textbox). E.g., textbox1 string is: 10,11,12 --> Total =33. Or, 1,33,121,3,55 ---> Total = 213. Below is my code so far. Thanks in advance! Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s, showVal As String Dim Total, x, length As Integer Dim comma1Position As Integer 'this is used to get the index of the first comma position Dim oldcomma1Position As Integer 'dummy register variable Dim commaCount As Integer = 0 s = TextBox1.Text length = s.Length x = 0 comma1Position = 0 oldcomma1Position = 0 commaCount = 0 Dim number As String Total = 0 Do While x <> -1 oldcomma1Position = comma1Position x = s.IndexOf(",") comma1Position = s.IndexOf(",", (oldcomma1Position + 1)) number = s.Substring(oldcomma1Position, x) Total = Total + CInt(number) commaCount = commaCount + 1 Loop showVal = " The Sum Total of the Comma Separated Values You Entered Is: " & Total MessageBox.Show(showVal)
Your answer will be ready within 2-4 hrs. Meanwhile, check out other millions of Q&As and Solutions Manual we have in our catalog.
Crazy for Study is a platform for the provision of academic help. It functions with the help of a team of ingenious subject matter experts and academic writers who provide textbook solutions to all your course-specific textbook problems, provide help with your assignments and solve all your academic queries in the minimum possible time.
Disclaimer: Crazy For Study provides academic assistance to students so that they can complete their college assignments and projects on time. We strictly do not deliver the reference papers. This is just to make you understand and used for the analysis and reference purposes only.