Frank,
I don't know if this "1 2 3 4 "thing is just an example or
if you want to do something more with expressions.
If you fi. also want 10 from "2*5" etc then you should
look at ABC\Algorithms. There are a few polish expression-
parsers(one by William Yiu himself)which basically does the
thing. Also on my homepage you can find several sources
adressing expressionparsing from a different point of view
(recursive).
Otherwise, if you only want to read stringintegers to integers
then there are a few easy measures to take:
1) Read in a string. When you reach a separator( in your case a space
or cr), you quit inputting. The inputstring can then be translated
using: a%=val(ltrim$(rtrim$(valstring$)))
For the way you have to read one key at the time you could use
Don's source in ABC\FAQs about INKEY.
Since probably you are not allowing for long integers/doubles, a good
program must also test the stringvalue if its in the bounds( you can
see some source for that in the opcode generator on my homepage).
This way it doesn't really matter how much spaces there are between
the integers. If you want you can also ignore cr's when the last
integer is not reached with something like this:
nrints=10
dim intarray[nrints-1]
for i=0 to nrints-1 'say you need 10 integers.
do: i$=getkey$: loop while iswhite(i$)
instring$="":
do
intstring$=intstring$+i$
i$=getkey$ 'see Don's sources..
loop until i$=' ' or i$=chr$(13) or i$=chr$(10)
intarray[i]=val(ltrim$(rtrim$(intstring$)))
next
'As an exercise I left the iswhite function.
Rick
[Now you tell me where in Visual Basic you put your
basic code( I only saw windows,buttons and the like ;))))
Quote:
>Hi, VB Experts:
>I have a simple question. Here is a string: "1 2 3 4" and
>I want to read it into four variables. How do I do that? The spaces vary from
>string to string, but they only have four numbers. Your help is
>greatly appreciated.
>Sincerely,
>Frank