Hello!
I'm new to this forum, and pretty much new to programming. However I do have previous knowledge of php and some java, if that helps.
I am trying to create a programme, that after given a list of numbers, can reduce or increase the percentage of only specfic numbers by a given amount from the user.
I haven't explained myself very well - but this is the format of code users will be entering -
52, 30, -20, 0, 19, 0, 0, 0, 0, -1, 40, 0, 0, 0
They will be inputted in this exact format, all separated by commas
The numbers I would like to solely reduce/increase, at the same percentage are the second, third, fourth and eleventh numbers. (30, -2, 0, 40)
They will be entering several lines of this code at once, and I would like the output to just change the numbers I have specified, by the percentage inputted.
I know the code to reduce percentage by the amount specified
dim a,b as integer
a=TextBox1.Text
b=TextBox2.Text
Label1.text=a*(1-b/100)
and to increase:
dim a,b as integer
a=TextBox1.Text
b=TextBox2.Text
Label1.text=a*(1+(b/100))
However I don't really have an idea how to change more than one number, and on several different lines.
Thank you very much to whoever can help me - and sorry if I sound really stupid!
Emily
edit: I will be using VB 10
4 replies to this topic
#1
Posted 27 July 2011 - 05:44 AM
|
|
|
#2
Posted 27 July 2011 - 06:48 AM
In many languages, you need to dim a and b as floats, or you will be doing integer arithmetic and end up NOT changing anything.
If you read the numbers into a listbox, or something similar, then you could access them by index.
If you read the numbers into a listbox, or something similar, then you could access them by index.
#3
Posted 28 July 2011 - 01:31 AM
I'm sorry but I don't quite get what you mean. upon entering the nos., are they entered using a single text box or different textboxes, coz if they are entered separately, you could actually make use of the textbox property of vb and do type casting since the default value of textboxes in vb is STRING. I hope I have helped.
#4
Posted 29 July 2011 - 07:48 AM
Thanks a lot for replying!
The coding will be entered in one text box, as there may be large quantities (hundreds) copy/pasted from another program.
The coding will be entered in one text box, as there may be large quantities (hundreds) copy/pasted from another program.
#5
Posted 23 August 2011 - 01:45 AM
try using a loop in getting all the numbers then put them in an array.
for example, since the numbers are seperated by comma(",")
make the loop save the characters before the comma to an array. that way you can indexed each value.
hope that helps.
for example, since the numbers are seperated by comma(",")
make the loop save the characters before the comma to an array. that way you can indexed each value.
hope that helps.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









