Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Visual Basic Form Names

Options
  • 18-10-2010 3:22pm
    #1
    Registered Users Posts: 82 ✭✭


    I'm working on a text editor on Visual Basic. I have a Save As function and I want the text property of the form to change to the name the user has chosen for the file.

    So far I can get the entire file name i.e. C:\Temp\Example 1.doc

    by using...

    Me.Text = sfd.FileName 'where sfd is my save file dialog component.

    In this example I want the form text property to change to "Example 1"

    Any ideas???


Comments

  • Registered Users Posts: 1,456 ✭✭✭FSL


    Scan the file name until you find the last occurrence of a '\' then scan for the '.'

    The name you want is the bit in between.


  • Moderators, Business & Finance Moderators Posts: 10,306 Mod ✭✭✭✭Jim2007


    Assuming that you are working with VB.Net then look at the class: System.IO.Path. It should give you all the methods you need...

    Jim.


  • Registered Users Posts: 2,781 ✭✭✭amen


    might be quicker to scan backwards and look for the first "\" :-)


  • Closed Accounts Posts: 48 BingoMingo


    If the Folder is always "C:\Temp\" then use the replace function to
    replace "C:\Temp\" with "" and ".doc" with ""


  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    As per Jim2007's suggestion, you should look at the System.IO.Path namespace, it has a lot of static utility methods for this kind of thing.

    See item #4 on this article (code's in C#, but it's the same thing);
    http://geekswithblogs.net/BlackRabbitCoder/archive/2010/09/09/c.net-five-final-little-wonders-that-make-code-better-3.aspx


  • Advertisement
Advertisement