In need of help (Using QB4.5) - READ! 
Author Message
 In need of help (Using QB4.5) - READ!

How can I cut a variable string into sections of 9 or less?? please



Mon, 04 Dec 2000 03:00:00 GMT  
 In need of help (Using QB4.5) - READ!

Quote:

>How can I cut a variable string into sections of 9 or less?? please


DIM Str AS STRING, Part(1 TO 9) AS STRING
DIM LStr AS INTEGER, LPart AS INTEGER, NbrParts AS INTEGER, Ptr AS INTEGER

INPUT "Enter string: ", Str

LStr = LEN(Str)         ' ** Divide Str into 9 or less Parts **
LPart = LStr \ 9
IF (LPart * 9 < LStr) THEN LPart = LPart + 1
NbrParts = 0: Ptr = 1
WHILE (LStr > 0)
   NbrParts = NbrParts + 1
   Part(NbrParts) = MID$(Str, Ptr, LPart)
   Ptr = Ptr + LPart
   LStr = LStr - LPart
WEND

FOR I% = 1 TO NbrParts   ' ** Show Result **
   PRINT I%; Part(I%)
NEXT
END
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove numbers from email id to respond)



Mon, 04 Dec 2000 03:00:00 GMT  
 In need of help (Using QB4.5) - READ!

|> How can I cut a variable string into sections of 9 or less??

You'll need to use the MID$ function. (Don't confuse this
with the MID$ statement that is used on the LEFT side of
the "=".)

Example of MID$ function:

  A$ = "This is a test."
  B$ = MID$(A$, 2, 9)    'makes B$ = "his is a "

You'll probably want to call MID$ in a loop, so you'll need
to establish a criterion for breaking out of the loop when
you're done breaking up the string.

If you want to store the sections and use them later, DIM
an array for them. You can figure out how big to make the
array by getting the LEN of the original string, and
calculating how many sections of 9 or less it contains.

Since your question could easily be a homework assignment,
I'll leave the rest up to you. Look up MID$, LEN, DIM
and maybe FOR/NEXT and DO/LOOP in the help system. For extra
credit, play around with MOD and integer division (\ instead of /).

--
Brian McLaughlin, Technical Writer  |"Thanks to the Internet, misinformation
Integrated Measurement Systems, Inc.| now travels faster than ever before!"
Beaverton, OR, USA                  | ---- Standard disclaimer applies ----



Mon, 04 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. pls help - how to read from qb4.5 the version number of the OS

2. HELP! - Reading Btrieve Data in QB4.5

3. MEMORY HELP NEEDED IN QB4.5

4. QB4.5 help needed

5. Beginner needs help w/DO LOOP UNTIL in QB4.5 :)

6. Help needed in QB4.5 (Joystick/Mouse)

7. Newbie needs help in reading installed programs from the registry using RegObj.dll

8. Newbie needs help in reading installed programs from the registry using RegObj.dll

9. Need help: Using VB4 to read time off connection status box

10. Newbie needs help in reading installed programs from the registry using RegObj.dll

11. RP: Need help - reading/writing binary values using regobj.dll

12. Need help - reading/writing binary values using regobj.dll

 

 
Powered by phpBB® Forum Software