|
-
Apr 25th, 2002, 10:31 AM
#1
Thread Starter
Fanatic Member
Cutting off last4 characters
How can I trim the last 4 characters off of a string? Like:
strSong= "Superdrag - Baby Goes To Eleven.mp3"
I want to cut the last 4 characters (.mp3) off of the string and save as a new string.
strNew= Function I need here(strSong)
Any help appreciated.
-
Apr 25th, 2002, 10:33 AM
#2
abc = Left(abc, Len(abc) - 4)
-
Apr 25th, 2002, 10:34 AM
#3
Thread Starter
Fanatic Member
Also, how can I?
How can I check to see if a character exists in a string? Say if I want to check my string for a comma.
-
Apr 25th, 2002, 10:34 AM
#4
VB Code:
strSong = left(strSong, len(strSong) - 4)
-
Apr 25th, 2002, 10:36 AM
#5
Bouncy Member
Re: Also, how can I?
Originally posted by hipopony66
How can I check to see if a character exists in a string? Say if I want to check my string for a comma.
VB Code:
If InStr(str,",") > 0 Then Msgbox "Yup!"
-
Apr 25th, 2002, 10:36 AM
#6
Addicted Member
locationInString = InStr(1, yourString, ",")
-
Apr 25th, 2002, 10:37 AM
#7
Re: Also, how can I?
Originally posted by hipopony66
How can I check to see if a character exists in a string? Say if I want to check my string for a comma.
VB Code:
If InStr(1, strSong, ",", vbTextCompare) Then
'Its in there
End If
TextCompare is not case sensetive, BinaryCompare is.
-
Apr 25th, 2002, 10:37 AM
#8
Re: Also, how can I?
Originally posted by hipopony66
How can I check to see if a character exists in a string? Say if I want to check my string for a comma.
if instr(string,",") then
msgbox("comma exists")
end if
(btw, instr gives the position of that comma)
edit: corrected
-
Apr 25th, 2002, 10:41 AM
#9
first last. crap.
-
Apr 25th, 2002, 10:48 AM
#10
Thread Starter
Fanatic Member
Still one problem......
Trim off thing isn't working.
My code is like:
How would I cut the last 4 characters off of temp(0)?
-
Apr 25th, 2002, 10:54 AM
#11
Thread Starter
Fanatic Member
This doesn't work either
VB Code:
tmpartist = temp(0)
artist = Left(tmpartist, Len(tmpartist) - 4)
-
Apr 25th, 2002, 10:54 AM
#12
Bouncy Member
VB Code:
artist = Left$(temp(0), Len(temp(0)-4))
-
Apr 25th, 2002, 10:59 AM
#13
Thread Starter
Fanatic Member
Not cutting it off
It's still not cutting off the ".mp3". It doesn't make any sense to me
-
Apr 25th, 2002, 11:10 AM
#14
Bouncy Member
can you paste your code exactly and a few lines before and after it please?
-
Apr 25th, 2002, 11:18 AM
#15
Thread Starter
Fanatic Member
Ok, here goes...
VB Code:
Dim genretemp As String
Dim hastag As Boolean
Dim Tag As String * 3 ' First 3 Chars of 128 byte Tag Info - 'TAG'
Dim Songname As String * 30
Dim artist As String * 30
Dim album As String * 30
Dim year As String * 4
Dim comment As String * 30
Dim genre As String * 1
Dim temp() As String
Dim x As Integer
Dim mp3 As String
lbltotal.Caption = File1.ListCount
On Error Resume Next
'start the loop
For x = 0 To File1.ListCount - 1
lblcurrent = x + 1
filename = Dir1.Path & "\" & File1.List(x)
mp3 = File1.List(x)
temp = Split(mp3, " - ") 'split up the info
'check for other exiting ID3 info
Open filename For Binary As #1
Get #1, FileLen(filename) - 127, Tag
If Not Tag = "TAG" Then
Close #1
hastag = False
Exit Sub
End If
hastag = True
filename = filename
Get #1, , Songname
Get #1, , artist
Get #1, , album
Get #1, , year
Get #1, , comment
Get #1, , genre
Close #1
'''''''''end of reading file''''''''''''''''''
'remember the other fields
album = RTrim(album)
year = RTrim(year)
comment = RTrim(comment)
genretemp = RTrim(genre) 'read gengre character to "temp"
genre = Asc(genretemp) 'convert chr-code to ASCII-number
Tag = "TAG"
artist = Left$(temp(0), Len(temp(0)) - 4)
Songname = temp(1)
'Write the tag
Open filename For Binary Access Write As #1
Seek #1, FileLen(filename) - 127
Put #1, , Tag
Put #1, , Songname
Put #1, , artist
Put #1, , album
Put #1, , year
Put #1, , comment
Put #1, , genre
Close #1
DoEvents
Next
End Sub
-
Apr 25th, 2002, 11:29 AM
#16
Bouncy Member
thats coz you done it to the wrong variable ya plonker.
change
VB Code:
artist = Left$(temp(0), Len(temp(0)) - 4)
Songname = temp(1)
to
VB Code:
artist = temp(0)
Songname = Left$(temp(1), Len(temp(1)) - 4)
-
Apr 25th, 2002, 11:30 AM
#17
Bouncy Member
PS: no offence, only messing
-
Apr 25th, 2002, 11:38 AM
#18
Thread Starter
Fanatic Member
Son of a!!!!!!!
I noticed that before I read your post! I was looking at the ID3 info in Explorer (Win XP) and I noticed that all of my artist names were 4 characters short! Thanks for the help.
-
Apr 25th, 2002, 11:41 AM
#19
-
Apr 25th, 2002, 11:42 AM
#20
No offence, but it's true!!!
-
Apr 26th, 2002, 03:44 AM
#21
Bouncy Member
-
Apr 26th, 2002, 03:45 AM
#22
Bouncy Member
-
Apr 26th, 2002, 03:52 AM
#23
I've only seen Mr.Bean on the world's most ****ED UP channel, PBS. Other than that, I have no source to watch any british sitcom.... Unless it's on BBC, but it's reception is pretty poor, here in Mongolia.
-
Apr 26th, 2002, 04:05 AM
#24
Bouncy Member
well, for what its worth i havent seen any mongolian sit-coms either
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
|