View Full Version : پاک کردن یک خط خاص در تکستباکس
  
niksalehi
جمعه 30 تیر 1391, 23:00 عصر
سلام به همه...
میخوام مثلا خط پنجم از تکستباکس رو دیلیت کنم، گشتم اما برای ریچ تکستباکس بود نه تکستباکس!
سوال بعدی:
DON'T cry over anyone who won't cry over you
Good FRIENDS are hard to find, harder to leave, and impossible to forget
You can only go as far as you push
DON'T cry over anyone who won't cry over you
ACTIONS speak louder than words
مثلا جمله های بالا در تکستباکس ما هستش، میخوام خط هایی که اولش با DON`T شروع میشه رو دیلیت کنم! آیا راهی هست؟
محسن واژدی
جمعه 30 تیر 1391, 23:13 عصر
سلام علیکم
میتوانید از توابع پست زیر کمک بگیرید:
http://barnamenevis.org/showthread.php?332045-%D8%B3%D8%A4%D8%A7%D9%84-%D8%AF%D8%B1-%D9%85%D9%88%D8%B1%D8%AF-%D8%B1%D8%A7%D8%B3%D8%AA-%DA%A9%D9%84%DB%8C%DA%A9-%D9%88-%D8%AA%DA%A9%D8%B3%D8%AA&p=1462743&viewfull=1#post1462743
موفق باشید
arenaw
شنبه 31 تیر 1391, 03:10 صبح
سلام
این فانکشن هارو کپی کن تو مادژول
Function IsMultiLine(ByVal str As String) As Boolean
    If Not InStr(1, str, Chr(13) & Chr(10)) = 0 Then IsMultiLine = True
End Function
Function DeleteLine(ByVal str As String, ByVal line As Integer) As String
    If IsMultiLine(str) = False Then
        If Not line = 1 Then
            DeleteLine = str
        End If
    Else
        Dim a$()
        a = Split(str, Chr(13) & Chr(10))
        For i = LBound(a) To UBound(a)
            If Not i = line - 1 Then DeleteLine = DeleteLine & a(i) & vbNewLine
        Next i
        DeleteLine = Mid(DeleteLine, 1, Len(DeleteLine) - 2)
    End If
End Function
Function AllLine(ByVal str As String) As Integer
    If IsMultiLine(str) = False Then
        AllLine = 1
    Else
        Dim a$()
        a = Split(str, Chr(13) & Chr(10))
        AllLine = UBound(a) + 1
    End If
End Function
Function ReadLine(ByVal str As String, ByVal line As Integer) As String
    If IsMultiLine(str) = False Then
        If line = 1 Then ReadLine = str
    Else
        Dim a$()
        a = Split(str, Chr(13) & Chr(10))
        If Not line - 1 > UBound(a) Then
            ReadLine = a(line - 1)
        End If
    End If
End Function
این واسه سوال اولت :
Text1.Text = DeleteLine(Text1.Text, 5)
اینم واسه دومی:
Dim i&
For i = 1 To AllLine(Text1.Text)
    If UCase(ReadLine(Text1.Text, i)) Like "DON'T *" Then Text1.Text = DeleteLine(Text1.Text, i)
Next i
niksalehi
یک شنبه 01 مرداد 1391, 01:04 صبح
ممنون از ماژول خوبت دوست من اما تو مورد دوم اکثر مواقع درست کار نمیکنه، چرا؟ :-؟
مثلا:
Beautiful as a dream.
The love we shared made everything so beautiful in life.
Beautiful countryside.
A stunningly beautiful, asymmetric crystal came from the fountain of lourdes in france.
Beautiful to look at, the cityscape in winter particularly memorable, and yet remains parochial and small minded.
Then i'll fit right in on myspace: ) just kidding - you peeps all look beautiful.
Beautiful in appearance and comfortable in the hand.
Beautiful with four poster and half tester beds and the drawing room has a piano.
Beautiful scenery in the world.
With the settings at their highest everything looks breathtakingly beautiful.
Private Sub Command1_Click()
Dim i&
For i = 1 To AllLine(Text1.Text)
    If UCase(ReadLine(Text1.Text, i)) Like "Beautiful *" Then Text1.Text = DeleteLine(Text1.Text, i)
Next i
End Sub
اما هیچ خطی رو پاک نمیکنه!
meys34
یک شنبه 01 مرداد 1391, 01:26 صبح
با تشکر از کدی که arenaw (http://barnamenevis.org/member.php?203395-arenaw) زحمتش رو کشیده بودند:لبخندساده::لبخندساده: :قلب::قلب:
Private Sub Command1_Click()
Dim i&
For i = 1 To AllLine(Text1.Text)
    If UCase(ReadLine(Text1.Text, i)) Like UCase("Beautiful *") Then Text1.Text = DeleteLine(Text1.Text, i)
Next i
End Sub
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.