-
Pro-blem
Hi,
string = C:\Something\Something\Something and something\
I need code which will be doing something like this with above string:
(Click!)
string = C:\Something\Something\
(Click!)
string = C:\Something\
(Click! :-)
string = C:\
it's f hard
-
Hi MeandMe
Try this
'Create a new form with one text box and one command button
'Milton Neal miltonneal@arach.net.au
Option Explicit
Dim strLen As Integer
Dim strText As String
Private Sub Command1_Click()
Dim lofs As Integer ' Length of string
Dim c As Integer ' Counter
Dim strTemp As String 'Temp string buffer
lofs = strLen
strTemp = Left(Text1.Text, lofs)
For c = 1 To lofs
If Left(Right(strTemp, c), 1) = "\" Then 'Get the last char of the string and compare with \
strTemp = Left(Text1.Text, lofs - c + 1) 'Move it int the text box
Text1.Text = strTemp
strLen = Len(strTemp) - 1 'Save the new string length minus the \
Exit Sub 'Done
End If
Next c
End Sub
Private Sub Form_Load()
strText = "C:\something\something\or something"
Text1.Text = strText
strLen = Len(strText)
End Sub
-
VERY good code!
Thanx for it
-
Hi again
Wasn't thinking to well last night .. but who does at 1 in the morning ...lol
Just a small change to the command click ... just incase the initial string ends with the '\' character. ... good luck
Private Sub Command1_Click()
Dim lofs As Integer ' Length of string
Dim c As Integer ' Counter
Dim strTemp As String 'Temp string buffer
If Right(Text1.Text, 1) = "\" Then strLen = Len(Text1.Text) - 1 'See if the last char is a \
lofs = strLen
strTemp = Left(Text1.Text, lofs)
For c = 1 To lofs
If Left(Right(strTemp, c), 1) = "\" Then 'Get the last char of the string and compare with \
strTemp = Left(Text1.Text, lofs - c + 1) 'Move it int the text box
Text1.Text = strTemp
strLen = Len(strTemp) 'Save the new string length
Exit For 'Done
End If
Next c
End Sub
-
You might also look at the InStrRev function. ;-)
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Similar Threads
-
By Evgeniy Chanyshev in forum vb.announcements
Replies: 0
Last Post: 05-21-2003, 09:01 AM
-
By Murray Foxcroft in forum Web
Replies: 0
Last Post: 04-23-2002, 02:09 AM
-
By Marco in forum VB Classic
Replies: 0
Last Post: 03-05-2002, 10:17 PM
-
By MightyMouse in forum VB Classic
Replies: 1
Last Post: 08-21-2001, 12:37 AM
-
By Scot Naef in forum Database
Replies: 8
Last Post: 01-11-2001, 08:49 AM
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks