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

Write a long note on the viewfinder of a camera, Question 1 What are the d...

Question 1 What are the different kinds of editing? Explain them in detail Question 2 Write a long note on the viewfinder of a camera Question 3 Describe the various typ

Explain the characteristics of vector processing, Question 1 Draw the bloc...

Question 1 Draw the block diagram of von Neumann Architecture and explain about its parts in brief Question 2 Draw the block diagram of Intel 8085 CPU organization and explai

What are the different types of props, Question 1 Explain the importance o...

Question 1 Explain the importance of edge loops and anatomical body functions in animation Question 2 What are the three sets of curves for the hair system? Questio

Internal storage, Internal Storage: Internal storage is also known as ...

Internal Storage: Internal storage is also known as main, primary, or (for historical reasons) core storage, or, memory. It is used to hold those instructions and data require

Identify important elements of multimedia, Problem 1 Identify important...

Problem 1 Identify important elements of Multimedia and explain with example. Stating important elements of Multimedia with example of each Problem 2 Explain a

As, access,excel and ms word/

access,excel and ms word/

Wat do u do, can u write my assignment for me

can u write my assignment for me

Describe 3 components of a pattern, QUESTION (a) Compare the adapter pa...

QUESTION (a) Compare the adapter pattern with the façade and decorator patterns. (b) Illustrate a two-way adapter pattern. (c) Describe 3 components of a pattern. (d)

Project of interactive powerpoint in human computer , Hi There, can you h...

Hi There, can you help me with my small project please, i have sent it yesterday and you dont replay. can you please ethir lem me know you can do it or no Regrads Meshari

Provide a goms description of the procedure, Question : (a) You want to...

Question : (a) You want to perform the task of sending an e-mail message to three of your friends. You can assume that the email addresses, of the people you want to send the e

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