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

Widening web, The Widening Web The idea, the whole world is agog...

The Widening Web The idea, the whole world is agog now had accidental origins. Here is how it all began. In early 1969, the U.S. Defence department financed a network fo

Central processing unit, Central Processing Unit: A Central Processing...

Central Processing Unit: A Central Processing Unit (CPU) in a computer system is an extremely fast device as compared to the main memory, but it can not work on its own. It de

C++, how to use expressions in c++ program with examble

how to use expressions in c++ program with examble

Define CISC and RISC ?, Two competing architectures were developed for impr...

Two competing architectures were developed for improving the architecture of the central processing unit, and different processors are conventional to each one. Both had their powe

#title., what is input and output device? explain meaning of input and outp...

what is input and output device? explain meaning of input and output devices

Languages, Languages The language is a program containing rules and...

Languages The language is a program containing rules and guidelines to help us in making programs. There are various languages like C, Basic, COBOL, PASCAL, FORTRAN etc. Th

Block diagram of computer, Input unit: These are used to read data and tran...

Input unit: These are used to read data and transfer to primary memory contained in CPU through keyboard or floppy disk or mouse etc. Central Processing Unit (CPU): This consists o

Assignment of making a small database, assignment of making a small databas...

assignment of making a small database in C# with a back end support of MS Access. i required a form with following options : Enter a new user (user name, father name, age, d

Search strategies, Search strategies are evaluated along four main dimensio...

Search strategies are evaluated along four main dimensions. Name those dimensions and briefly describe each one

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