|
-
Jun 9th, 2000, 02:05 PM
#1
Thread Starter
Junior Member
Hi, i'm making a program, and i need it to do the following things.(It uses a textbox to display a text file)
1) I need it to go to a new line when the little square symbol is found, and then the second time it finds it in that line, it needs to delete it and everything after it on that line
Thanks for any help!
-
Jun 9th, 2000, 07:20 PM
#2
_______
square
post a small text file of the file type you are reading.
I have no idea what 'little square' you are talking about.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 9th, 2000, 11:11 PM
#3
Just use the InStr function to search for the Little Sqaure and then insert the line by using the vbNewLine command.
-
Jun 9th, 2000, 11:48 PM
#4
I think those "Little Squares" are probably linefeeds and carriage returns [chr(11) and chr(13) I think...] if this file came from something like notepad. Use InStr to find these.
I thought VB didn't display these if the multiline property is set on the textbox but I don't remember. Maybe try using a richtext box on the chance that they are some other formatting.
-
Jun 10th, 2000, 12:57 AM
#5
Addicted Member
Yes Royce must be right !
ef2k must be using the text box without the multiline
property being true...
In that case nothing is needed - just set the multiline
property to true.
If you can't pronounce my name, call me GURU 
-
Jun 10th, 2000, 02:25 AM
#6
Thread Starter
Junior Member
call me Eric hehehe
Ok that part is solved (the problems with the carriage returns,it just looked that way in notepad, not in a RichTextBox) anyways, here's a sample line
ADD-
looser:24hUwwZzC3ERw|looser:1000291212:19990415:19990422:7
^
I need it to delete
everything past the symbol the arrow is under and also the symbol itself, which now
appears to have been a pipe all along, not sure though if it is a pipe or a CARRIAGE RETURN , and yes i meant the square as in the carriage return character, i couldn't think of the name at the time
-
Jun 10th, 2000, 02:26 AM
#7
Thread Starter
Junior Member
crap! it didn't format it right! ok then i'll just say i need it to delete everything past the pipe, and the pipe itself, thanks for all your help and any further help, you guys have really taught me alot
-
Jun 10th, 2000, 09:47 PM
#8
_______
inStr
'to check this out. use
'Form = Form1
'TextBox = Text1
'Command button = Command1
Option Explicit
'' A textual comparison starting at #1 position (W)
'one drawback...if you have only one line of text with no
'carriage return, the seach will = 0 since there is no carriage return
Private Sub Command1_Click()
Dim SearchString, SearchChar, MyPos
SearchString = Text1.Text ' String to search in.
SearchChar = vbCrLf ' Search for "P".
MyPos = InStr(1, SearchString, SearchChar, 1)
'if found MyPos will be > 0
If MyPos > 0 Then
MsgBox "String found at " & MyPos
'my code = delete rest of string
'I just rewrite the string ..you would save the new string as your file
' or whatever or whatever.
SearchString = Left(SearchString, 17)
Text1.Text = SearchString
Else
MsgBox "Not found...I guess I do nothing here. What do you say?"
End If
End Sub
Private Sub Form_Load()
'I loaded this just as an example
'you would of course open your file and read it into a string
'or text box or whatever your option choice
Text1.Text = "help me out here" & vbCrLf
Text1.Text = Text1.Text & "Is this a carriage return?" & vbCrLf
Text1.Text = Text1.Text & "Clean everything after first carriage return." & vbCrLf
Text1.Text = Text1.Text & "Gone"
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 11th, 2000, 04:36 AM
#9
Thread Starter
Junior Member
ok thanks wayne, that worked, but i also need to remove the "ADD-" part which i failed to mention *sorry!* and also, it needs to scan the whole file and do those operations on every line. also, i noticed you told it to stop at 17 and cut everything off after that, is there a way i can make it cut everything off after the pipe "|" instead? Here's another sample in case you need it
ADD-test:141607047|test:9000100006:1999-09-23:1999-09-24:1
^^^^
Needs to be deleted along with
"|test:9000100006:1999-09-23:1999-09-24:1"
-
Jun 11th, 2000, 07:59 AM
#10
Thread Starter
Junior Member
oh AND there are some lines that say "CLN-" and "KILL-" i would like to be able to delete the lines those words are on (they're at the beginning, just like add) so basically if it said
KILL-kevin123
or
CLN- AutoClean on 41299
i would like to delete those whole lines and THEN remove the "ADD-" from the beggining of the lines i'm keeping, which are ONLY the ADD lines, and then trim off the pipes and everything after it as i described in my previous postm thanks for any further help!
-
Jun 12th, 2000, 06:28 AM
#11
_______
?
Ok..give me what you want left
Give me three lines of your file and for each line
tell me what you want to be left with. I'll have a look at it. No promise I will work till I get an answer but I will have a look to see if I can kill it quickly.
example: assume this could be line 1
ADD-test:141607047|test:9000100006:1999-09-23:1999-09-24:1
what do you want to end up with
I need to see 3 lines to check it out properly
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 12th, 2000, 07:50 AM
#12
Thread Starter
Junior Member
Ok here's three sample lines:
CLN-Auto Cleanup on 19990512
EXPIRE-DAV37000
ADD-renee123:213/sVit3XRH2|renee123:00000:19901201:20031231:00
it should delte the first two whole lines automatically becuase they begin with CLN and EXPIRE, and then after it finds and deletes all those, it should then remove the
"ADD-" and the part after the "|" so i would be left with
renee123:213/sVit3XRH2
thanks for any help!
-
Jun 12th, 2000, 08:26 PM
#13
_______
Captain Morgan Is Fine
'this is all you get..it works for me...
'couldn't do it last night..the woman was
' playing checkers with the daughter in law
'new project
'listbox called List1
'Command button called Command1
'file on your C drive call ANEW.txt containing your information
' CLN-Auto Cleanup on 19990512
' EXPIRE-DAV37000
' ADD-renee123:213/sVit3XRH2|renee123:00000:19901201:20031231:00
Option Explicit
Option Compare Text
Private Sub Command1_Click()
Dim myVariable
Dim SearchString, SearchChar, MyPos
Dim sCount As Integer
Dim iArray()
Open "C:\anew.txt" For Input As #1
Do While Not EOF(1)
sCount = sCount + 1
Line Input #1, myVariable
ReDim iArray(1 To sCount)
If Left(myVariable, 3) = "ADD" Then
SearchString = myVariable ' String to search in.
SearchChar = "|" ' Search
MyPos = InStr(1, SearchString, SearchChar, 1)
SearchString = Left(SearchString, (MyPos - 1))
MyPos = InStr(1, SearchString, SearchChar, 1)
Dim sLen As Integer
sLen = Len(myVariable)
Dim nLen As Integer
nLen = Len(SearchString)
myVariable = Right(SearchString, (nLen - 4))
End If
If Left(myVariable, 3) = "CLN" Or Left(myVariable, 6) = "EXPIRE" Then myVariable = "kill"
iArray(sCount) = myVariable
If myVariable <> "kill" Then
'here you can write it to a different file if you like or whatever
'the list box just shows you what you get
List1.AddItem iArray(sCount)
End If
Loop
Close #1
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 13th, 2000, 06:20 AM
#14
Thread Starter
Junior Member
FINALLY!
Thanks for all your help Wayne, it finally worked (i just added the thing for "KILL-" which wasn't there, and changed it to a richtextbox.I'd just like you to know how appreciative i am of people like you who are willing to help out is relatively-new VBers. Thanks again. Eric
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
|