Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple return of a portion of a string 3

Status
Not open for further replies.

Greycon

IS-IT--Management
Mar 6, 2005
11
US
Hello,

I am looking for a simple way to return a portion of a
variable. ie mystring = string(1) to make mystring = s

Is there a way to do this?

I thought instr or len might work. Obviously the way I
tried did not work. Should be a simple way, just can't
think of it. Don't think I should have to use a array.

any suggestions?

Greycon
 
Not sure what programming language you are using, in VBA it would be:

string(1) = Left(mystring, 1)
 
Hi,

Code:
MyString = "string"
MyString = Left(MyString, 1)
'MyString now contains "s"
???

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Sub aa()
Dim string1 As String
Dim mystring As String
string1 = Sheets(1).Range("A1").Value
mystring = Left(string1, 1)
MsgBox mystring
End Sub

Regards
Ken............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
Love the new time feature - Don't feel like a plonker now :)

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 

Holy mackerel! [fish2] <rolling eyes>

An entire subroutine, instead of a code segment!

KenWright, the weekend VBA warrior!

How long were the in-laws in town? ;-)

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
rotflmao - I'm going to trawl through the small ads for some hired help up in your area to come and slap that damn fish around your head <g>

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 


What, Ken?

No "football" or cricket on the tellie?

No blokes to share a stout 'n' a game of darts?

;-)

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Wow that was quick!

yes I am using VBA in excell.
been working on this project for a week now
and my mind is fried. string(1) = Left(mystring, 1)
is exactly what I was looking for.

Thanks

Greycon
 
Curled up on the sofa, watching a televison drama (Wireless laptop at the ready for the intervals). That covers me till about 23:00. Pick son up from bus stop at 23:30, another hour or so playing on here and then settle down for the night till the joyous occasion of being able to go to work comes around in the morning. :)

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 


Ouch! Ichth!

rolflmao

l........

l...............

l........................................

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Quick!! Quick!!! - You had to wait at least 11 min before getting help - a disgusting state of affairs for which we are truly sorry. We will endeavour to do better next time, and only hope you can forgive us.

Well, it's sunday :)

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
LOL

11 min. If I could get my people to work that
fast, I would not be working at home on sunday.

Thanks again.
 


Grecon,

Be sure to thank Ken -- see the lower LH link in Ken's posts.

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
I just called off the Fish Slapper :)

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top