whoops didn't read the full message.

here is where you go wrong i think :)


>   location = words1.IndexOf("_new")
>
>   If location > 0 or not -1 then
>

location will give the location of the start of "_new"
you want the next char not the position of the "_"

then:        newstring_withnum_tostr = words1.substr (location + x, 1)
words1.replace (newstring_withnum_tostr, cint (newstring_withnum_tostr) + 
1 )

check it:

response.write (words1)





----- Original Message ----- 
From: "Tony Trapp" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 11, 2005 11:13 PM
Subject: [AspNetAnyQuestionIsOk] VB.net String maniplulation problem


> Hey guys here is what I want to do.
>
> Lets say I have a file name is my database my_pic_new1.jpg first off.
>
> Now I want to change this file name to make it a uniqe file name but
> I need to do a few things to the string first.
>
> Is in the string _new is there then I want to see if a number is
> there.
>
> If there is a number there I want to take that number and what ever
> it is increment that number up by one make the file now
> my_pic_new2.jpg
>
> and so on.
>
> I am not asking for someone to write the code for me but point me to
> where I can gain viable info on how to make this hapeen or a small
> code example.
>
> Here is my code at present,
>
>
>  Dim words1 as String = tmnescort_currentpic_small
>
>   Dim location as Integer
>   Dim Counter as Integer
>   Dim newstr as Integer
>   Dim newstring_withnum as Integer
>   Dim countvar as Integer
>   Dim newstring_withnum_tostr
>   dim addnum as String
>
>   Counter = 0
>   location = words1.IndexOf("_new")
>
>   If location > 0 or not -1 then
>
>        newstring_withnum_tostr = instr(1, words1, "1")
>
>
> newstr = System.Convert.ToInt16
> (newstring_withnum_tostr + 1)
> newstring_withnum = newstr & Counter + 1
> addnum = System.Convert.ToString(newstring_withnum)
>
>     str_msg.Visible = True
>     str_msg.Text = "This is the pic name in DB&nbsp;" &
> tmnescort_currentpic_small & "<br><br>new string was found<br><br>" &
> addnum & "<br><br>"
>
>        else
>
> str_msg.Visible = True
>     str_msg.Text = "This is the pic name in DB&nbsp;" &
> tmnescort_currentpic_small & "<br>new string was not found<br><br>" &
> addnum & "<br><br>"
>
>    end if
>
>
> what I get back printed out is
>
> This is the pic name in DB my_pic_new1.jpg
>
> new string was found
>
> 161 << this is what happens after my string manipualtion I dont want
> this.
>
> Can any please help me?
>
> Thanks,
>
> Tony...
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.11.8 - Release Date: 5/10/2005
>
> 



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to