that code should compile.

did you put that code in a method?


  ----- Original Message ----- 
  From: Tony Trapp 
  To: [email protected] 
  Sent: Wednesday, May 11, 2005 7:27 PM
  Subject: Re: [AspNetAnyQuestionIsOk] VB.net String maniplulation problem


  Dave I ran in your code in a c# page and this is the error I got,


  Server Error in '/' Application. 
  
--------------------------------------------------------------------------------

  Compilation Error 
  Description: An error occurred during the compilation of a resource required 
to service this request. Please review the following specific error details and 
modify your source code appropriately. 

  Compiler Error Message: CS1519: Invalid token 'if' in class, struct, or 
interface member declaration

  Source Error:

       
  Line 5:  Regex r = new Regex( @"_new(?<count>\d+)" );
  Line 6:  Match m = r.Match( fn );
  Line 7:  if( ( m != null ) && ( m.Groups[ "count" ].Value.Length >0 ) )
  Line 8:  {
  Line 9:  string current = m.Groups[ "count" ].Value; 

    ----- Original Message ----- 
    From: dave wanta 
    To: [email protected] 
    Sent: Wednesday, May 11, 2005 4:38 PM
    Subject: Re: [AspNetAnyQuestionIsOk] VB.net String maniplulation problem


    it's a C# thing.

    The @ symbol just escapes any of the C# sequences (so you don't have the 
escape the regex escape characters).

    so, 
    @"_new(?<count>\d+)"
    is  the same as
    "_new(?<count>\\d+)"

    Cheers!
    Dave
      ----- Original Message ----- 
      From: Tony Trapp 
      To: [email protected] 
      Sent: Wednesday, May 11, 2005 6:07 PM
      Subject: Re: [AspNetAnyQuestionIsOk] VB.net String maniplulation problem


      Dave the @ symbol seems to me that it means at _new but the rest 
(?<count>\d+) what is it that its doing.

      The rest makes sense to me.

      Tony...

        ----- Original Message ----- 
        From: dave wanta 
        To: [email protected] 
        Sent: Wednesday, May 11, 2005 3:37 PM
        Subject: Re: [AspNetAnyQuestionIsOk] VB.net String maniplulation problem


        Hi,

        this is off the top of my head in C#, but it should work. You should be 
able to translate it, or someone on here might be able too.

        string fn = "my_pic_new2.jpg";
        Regex r = new Regex( @"_new(?<count>\d+)" );
        Match m = r.Match( fn );
        if( ( m != null ) && ( m.Groups[ "count" ].Value.Length >0 ) )
        {
        string current = m.Groups[ "count" ].Value;
        int next = int.Parse( current ) + 1;
        fn = fn.Replace( "_new" + current, "_new" + next.ToString() );
        }


        Cheers!
        Dave
          ----- Original Message ----- 
          From: Tony Trapp 
          To: [email protected] 
          Sent: Wednesday, May 11, 2005 4: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

            a.. To visit your group on the web, go to:
            http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
              
            b.. To unsubscribe from this group, send an email to:
            [EMAIL PROTECTED]
              
            c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service. 



        [Non-text portions of this message have been removed]



      
------------------------------------------------------------------------------
        Yahoo! Groups Links

          a.. To visit your group on the web, go to:
          http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
            
          b.. To unsubscribe from this group, send an email to:
          [EMAIL PROTECTED]
            
          c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service. 



      [Non-text portions of this message have been removed]



    
------------------------------------------------------------------------------
      Yahoo! Groups Links

        a.. To visit your group on the web, go to:
        http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
          
        b.. To unsubscribe from this group, send an email to:
        [EMAIL PROTECTED]
          
        c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service. 



    [Non-text portions of this message have been removed]



  ------------------------------------------------------------------------------
    Yahoo! Groups Links

      a.. To visit your group on the web, go to:
      http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
        
      b.. To unsubscribe from this group, send an email to:
      [EMAIL PROTECTED]
        
      c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



  [Non-text portions of this message have been removed]



------------------------------------------------------------------------------
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
      
    b.. To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]
      
    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



[Non-text portions of this message have been removed]



 
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