Home > Software engineering >  VB6 how to remove the specified text
VB6 how to remove the specified text

Time:09-24

yes, I have some address
E: \ \ xx xx ini
how to get rid of E: \ \, xx is \ and \ front part

CodePudding user response:

I'm sorry, this I use c #, VB, not apply to can't help you, really sorry,



CodePudding user response:

For "" can be used to remove shift character @ said,

For example, a path: E: \ Test1 and Test2, using the @ "E: \ Test1 and Test2" when the program is run by the program read the string is: "E: Test1 Test2",



CodePudding user response:

S=split (" E: \ \ xx xx ini ", "")

Msgbox s (ubound (s))

CodePudding user response:

Use InStrRev () and Mid $() function,
 Dim s $, i& 

S="E: \ \ xx xx ini"
I=InStrRev (s, "") 'to get the position of the last \ characters
(s, s=Mid $I + 1) 'capture finally that string

CodePudding user response:

 Private Sub Form_Load () 
As Integer Dim XX As A String, A, B As Integer
XX="E: \ \ XX, XX, XX, XXX, XXX, AA. Ini"
B=Len (XX) 'get the length of the string
A=InStrRev (XX, "") to detect the location of the last "",
XX, XX=Right (B - A) 'intercept string B - A position behind the string
'last variable is XX "AA. Ini", suitable for path no matter how long, all can get the file name + extension
End Sub

CodePudding user response:

The split. Can solve

CodePudding user response:

The original poster is to get the directory, reverse lookup is positive solution,

 Dim s $, i& 
S="E: \ \ xx xx ini"
MsgBox Left (s, InStrRev (s, ""))

CodePudding user response:

Said those with Split, are "as long as they can out of the results, regardless of efficiency",

CodePudding user response:

The
reference 3 floor Bobogg response:
s=split (" E: \ \ xx xx ini ", "")

Msgbox s (ubound (s))
with the split estimates are seeing the wrong topic, not taking the file name, but to directory, must use the split can also,

Both Dim s
 
S=Split (" E: \ \ xx xx ini ", "")
S (UBound (s))=""
MsgBox Join (s, "")

CodePudding user response:

references 9 f sysdzw response:
Quote: reference Bobogg reply: 3/f

S=split (" E: \ \ xx xx ini ", "")

Msgbox s (ubound (s))
with the split estimates are seeing the wrong topic, not taking the file name, but to directory, must use the split can also,

Both Dim s
 
S=Split (" E: \ \ xx xx ini ", "")
S (UBound (s))=""
MsgBox Join (s, "")

Is your wrong, the original poster is to "file name", not to the directory,

CodePudding user response:

references to the tenth floor Chen8013 response:
Quote: references 9 f sysdzw response:

Quote: refer to the third floor Bobogg response:

S=split (" E: \ \ xx xx ini ", "")

Msgbox s (ubound (s))
with the split estimates are seeing the wrong topic, not taking the file name, but to directory, must use the split can also,

Both Dim s
 
S=Split (" E: \ \ xx xx ini ", "")
S (UBound (s))=""
MsgBox Join (s, "")

Is your wrong, the original poster is to "file name", not to the directory,

really wrong

CodePudding user response:

Dim s As String

S="E: \ \ xx xx ini"
Dim s1 As String
S1=Replace (s, E: \ "xx", "")

CodePudding user response:

I am stupid way
S="E: \ \ xx xx ini"

For I=1 to 10
A=right (len (s) - instr (s, "\) - 1)

Next I
Msgbox a

Haven't test, you try, ha ha,
  • Related