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

Instruction pipeline, How branching takes place in Instruction pipeline. Ex...

How branching takes place in Instruction pipeline. Explain with suitable examples.

Output options to various multimedia, The various systems (computer, softwa...

The various systems (computer, software and output devices) that are available have different limitations for output that is cartographic in nature. Some systems are CAD, GIS limit

Software basics, SOFTWARE BASICS: Software is a generic term covering ...

SOFTWARE BASICS: Software is a generic term covering the concepts, procedures and instructions which cause the computer systems to accomplish the required job, Generally, soft

Encoder, What is an encoder? Draw the logic circuit of Decimal to BCD encod...

What is an encoder? Draw the logic circuit of Decimal to BCD encoder and explain its working.?

Cryptography, For which X,Y in {o, O, Theta, Omega, omega}, do the relation...

For which X,Y in {o, O, Theta, Omega, omega}, do the relationships t(n)+t''(n) = X(min(t(n),t''(n))) and t(n)+t''(n) = Y(max(t(n),t''(n))) hold for all t,t'' such that t(n),t''(n)

Input devices of a digital computer, Input devices of a digital computer: ...

Input devices of a digital computer: Input devices are used to read the instructions and data to be processed and output devices display the results obtained after executing t

Batch processing, Batch Processing When the entire computer system is d...

Batch Processing When the entire computer system is dedicated to a single job, the system is said to be operating in Batch Processing mode. In this mode each program is run to

Explain the types of memory and explain how each work, Problem: a) ...

Problem: a) Explain the basic functions of a computer: inputting, processing, storing and outputting. b) List four types of memory and explain how each wor

Programmable rom (prom) , PROGRAMMABLE ROM (PROM): The user can program...

PROGRAMMABLE ROM (PROM): The user can program a PROM after purchase.  Each memory bit element in the PROM contains a nichrome or silicon link that acts as a fuse.  The user can

Computational physiology, Estimate the mean deflection of the QRS complex i...

Estimate the mean deflection of the QRS complex in each of the six standard leads (I, II, III, aVR, aVL, aVF) in Figure 1 and then estimate the mean heart vector for the normal hea

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