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

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)
Posted Date: 11/15/2012 8:32:21 PM | Location : United States







Related Discussions:- Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION, Assignment Help, Ask Question on Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION, Get Answer, Expert's Help, Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION Discussions

Write discussion on Q: HOW DO YOU CODE -- WITHOUT USING ARRAYS OR SPLIT FUNCTION
Your posts are moderated
Related Questions
Magnetic tapes and Magnetic Disk: Magnetic tapes are very commonly used for storing large quantum of data for which rapid access is not necessary; specially for archival data

1. Write an algorithm and draw a flowchart to accept the names and gross salary of 5000 employees and to generate the net pay. If the gross salary is greater than N 50,000 declare

Task 1 Study various types of systems and simulate a system of your own. Task 2 Study various models and enumerate the various steps for designing a corporate model

Synchronous and Asynchronous Transmission: Another method of setting of terminals denotes synchronous or asynchronous transmission. Many terminals can only communicate in one

hitory and genration of computer

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

SOCIAL NETWORKING:  A social network is a network of individuals which have some sort of interdependence on each other. This interdependence may be in the form of friendship,


General Considerations for Search If we may specify the starting state, the operators and the goal check for a search problem, then we know from where to start, how to move and

I n t e rnal Structure of Agents We have looked at agents in terms of their external influences and behaviors: they take input from the environment and perform rational act