Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# why this is happenning ?

Posted on 2000-03-02
Medium Priority
145 Views
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
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
• 2

LVL 14

Accepted Solution

mcrider earned 200 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

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

ID: 2582827
Thanks a lot .

0

LVL 14

Expert Comment

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

0

## Featured Post

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
###### Suggested Courses
Course of the Month5 days, 17 hours left to enroll