Solved

why this is happenning ?

Posted on 2000-03-02
4
144 Views
Last Modified: 2010-05-02
like this im using the below statement.

Text1 = Trim(Mid(STRDATA, 1, 1))
Text2 = Trim(Mid(STRDATA, 2, 5))
Text3 = Trim(Mid(STRDATA, 8, 8))

the problem is on the third line, the data that should be shown on text  box is only 1 digit but why it show ten digits even i ask it to appear 1 digits only
ie 8 to 8 leght, even if i put  Text3 = Trim(Mid(STRDATA, 8 , 20)) it  
will show the same thing which is not correct data. how to ask it to appear the space or data that as our request.

pls help me.


thanks.
0
Comment
Question by:JOHNHO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 50 total points
ID: 2578833
Let's assume that STRDATA looks like this:

   STRDATA = "1234567890abcdefghij"

Then:

   Text1 = Trim(Mid(STRDATA, 1, 1)) 'WILL RETURN "1"
   Text2 = Trim(Mid(STRDATA, 2, 5)) 'WILL RETURN "23456"
   Text3 = Trim(Mid(STRDATA, 8, 8)) 'WILL RETURN "890abcde"

If you want Text3 to contain 1 character starting at position 8, you need to do this instead:

   Text3 = Trim(Mid(STRDATA, 8, 1)) 'WILL RETURN "8"


Hope this helps!


Cheers!

0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2579638
Yes, mcrider is right:

The first numeric parameter of the Mid command is the starting position. Your mistake is that you thought the second numeric parameter is the ending position. It's not - it's the number of characters you wish to return starting from the position specified in parameter 2.
0
 

Author Comment

by:JOHNHO
ID: 2582827
Thanks a lot .

0
 
LVL 14

Expert Comment

by:mcrider
ID: 2582921
Thanks for the points! Glad I could help!


Cheers!®©
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 6 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question