Click to See Complete Forum and Search --> : syntax
Pat S
October 12th, 2001, 08:58 AM
Can anyone tell me whay this does not work, and how to make it work. I have SiteNumbers that are 5 digits long and those that are 7. So, those below 00090, I need to pull in those 5 digits. Numbers over 00090, I need to pull in 7 digits. Here's the code I tried, and it will not work. If I just use the 00090, it takes off the 0s, and leaves me with a < 90.
Thanks
Pat
If Mid$(Trim(cmbSite.Text), 6) < 90 Then
strOnlySiteNumber = Mid$(Trim(cmbSite.Text), 3)
Else
strOnlySiteNumber = Left$(Trim(cmbSite.Text), 7)
End If
Cimperiali
October 12th, 2001, 09:06 AM
do not follow all but saw this
Mid$(Trim(cmbSite.Text), 6)
now,
mid$(string,start,len)
that is:
Mid$(Trim(cmbSite.Text), 6,2) takes 2 bytes starting from 6° char (char 6 and 7)
Mid$(Trim(cmbSite.Text), 1,6) takes 6 bytes starting from first (chars 1 to 6)
You've to be sure the string is long enough so:
if len(trim(text1.text)> 7 then 'you can get chars with mid till 8 position
ie: mid$(trim(text1.text),5,4) 'which takes from char 5 to char 8
...
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Pat S
October 12th, 2001, 09:21 AM
I probably didn't make this to clear. My application wouldn't accept both 5 and 7 digit SiteNumbers. So what we did was add 00 to the beginning of the 5 digit sites so now the length of all sites is 7 digits. But...when I download the data, I need a way for my app to distinguish between the 5 and 7 digit numbers. If I use the Mid$(trim(cmbSite.text), 3), it works fine for the 5 digit SiteNumbers, but it doesn't read the 7 digit ones, because I need all of the digits.
Thanks
Cimperiali
October 12th, 2001, 09:23 AM
'was this?
if isnumeric(text1.text) then
if cdbl(text1.text)> 90 then
'put it in 7 digits
else
'put it in 5 digits
end if
end if
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
DSJ
October 12th, 2001, 09:49 AM
Could you use a ComboBox instead of a textbox and allow them to choose the number rather than enter it?
Cimperiali
October 12th, 2001, 09:50 AM
>so now the length of all sites is 7 digits. But...
>when I download the data, I need a way for my app to distinguish
>between the 5 and 7 digit numbers
So, what can distinguish after you added "00"? Last two digits over or under 90?
then:
if len(trim(text1.text)> 1 then
if cint(right(text1.text,2))<90 then
'... short, so take it with mid$(text,3)
else
'... long so take last 7 (right(text, 7)
end if
else
'too short
end if
but question is
0000100 'this was a short one
and
0000093 'this was a long one
is the above true?
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.