Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION, Basic Computer Science

Assignment Help:
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)

Related Discussions:- Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION

Algorithms, write algotithm and flow chart for largest of 3 numbers

write algotithm and flow chart for largest of 3 numbers

Pipelining, tellme the types of pipelining

tellme the types of pipelining

COMPUTER ORGANIZATION, Ask questio2. Define interrupt n #Minimum 100 words ...

Ask questio2. Define interrupt n #Minimum 100 words accepted#

Define grid computing, Question 1 Define Grid computing Question 2 ...

Question 1 Define Grid computing Question 2 Explain Attribute-Based Programming Model for Grid Services Question 3 What are the characteristics that users/applicat

Explian, explain anatomy of digital coputer

explain anatomy of digital coputer

ExtremeWhether.html, How to crete a web page name esp.html that allows user...

How to crete a web page name esp.html that allows users to conduct an ESP test

Eeprom, Ask queswhat is the advanages of eeprom?

Ask queswhat is the advanages of eeprom?

Flow decomposition technique to list the cycles, QUESTION (a) Consider ...

QUESTION (a) Consider the graph below, use the Flow Decomposition technique to list the cycles and paths produced.                                                (b) Pr

Algorithm writing, algorithm to simulate railway reservation process

algorithm to simulate railway reservation process

Device drivers, Device Drivers:   Device drivers are shared computer p...

Device Drivers:   Device drivers are shared computer programs that provide an interface between the hardware devices and operating system or other higher level programs.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd