|
-
Nov 15th, 2003, 11:52 PM
#1
Thread Starter
New Member
Title Bar Help
I'm creating a notepad. When you save or open a text file its supposed to display the name of the file in the titlebar of the form. However, the way I have it coded, it displays the entire path of the file too. How do I get it to display just the name? Thanks.
VB Code:
Sub Titlebar()
Me.Text = CStr(documentName) & " - NotePad"
End Sub
-
Nov 16th, 2003, 12:07 AM
#2
Try This
Add this to the form or change Private to Public and put it in a module
VB Code:
Private Function GetFileName(ByVal strPath As String) As String
Dim strTmp() As String = Split(strPath, "\")
Return strTmp(strTmp.GetUpperBound(0))
End Function
Then use ur code like this:
VB Code:
Sub Titlebar()
Me.Text = getFileName(CStr(documentName)) & " - NotePad"
End Sub
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Nov 16th, 2003, 12:23 AM
#3
Thread Starter
New Member
-
Nov 16th, 2003, 02:00 AM
#4
PowerPoster
This functionality is built into the FileInfo object:
VB Code:
Dim fi As System.IO.FileInfo = New System.IO.FileInfo("C:\AFolder\AnotherFolder\MyTextFile.txt")
Me.Text = fi.Name & " - NotePad"
-
Nov 16th, 2003, 05:56 PM
#5
Originally posted by hellswraith
This functionality is built into the FileInfo object:
VB Code:
Dim fi As System.IO.FileInfo = New System.IO.FileInfo("C:\AFolder\AnotherFolder\MyTextFile.txt")
Me.Text = fi.Name & " - NotePad"
Yeah this is what I used.
Better than sticking in a loop.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|