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

Memory management, Memory Management: The purpose of the memory mana...

Memory Management: The purpose of the memory management system is to load programs into memory in such a way as to give each program loaded  the memory that it requires for

Differentiate the client–server and peer-to-peer models of d, The client-se...

The client-server model firmly differentiates the roles of the client and server. According to this model, the client requests services that are provided by the server. The peer-to

System software, note on high level language and low level language

note on high level language and low level language

Explain web cache, To satisfy client needs through proxy server and not thr...

To satisfy client needs through proxy server and not through main server, as some other user have already accessed that file and its copied to the proxy server, so next time a user

Create a database in access, The following are required: Create a ...

The following are required: Create a project in Access.  Your database must have flow and a theme. The database must be normalized.  The content m

How to Open a FCB files?, Opening files 0FH function is used to open an F...

Opening files 0FH function is used to open an FCB file the 21H interruption. The element, the name and extension of the file must be initialized previous to opening it. The DX regi

Probability, Suppose that of 100 computers checked for viruses 30 where inf...

Suppose that of 100 computers checked for viruses 30 where infected and 70 where not. If we select 10 computers at random what is the probability that at most 4 of them are infecte

#algorithm, #to determine whether given year is leap year or not

#to determine whether given year is leap year or not

Briefly explain html and xml, Question 1 Briefly explain principles of eff...

Question 1 Briefly explain principles of effective navigation Question 2 Explain the terms URI and URL. Why should you use Relative URI? Question 3 What are the di

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