Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Delete spesific line until last line

As title said, I need a help about it

Text:
Code
this text1
this text11
this text11
this text11

blabla

this text2

My code:
Code
Dim lines As New List(Of String)
        lines = txt1.Lines.ToList
        Dim FilterText = "(blabla )"

        For i As Integer = lines.Count - 1 To 0 Step -1
            If Regex.IsMatch(lines(i), FilterText) Then
                For u As Integer = lines.Count - 1 To lines(i) Step -1
                    lines.RemoveAt(u)
                Next
            End If
        Next
txt1.Lines = lines.ToArray

I want to delete line (blabla) until last line (this text2), but have a error in this part For u As Integer = lines.Count - 1 To lines(i) Step -1
Any help? thankyou
As the title "spesific" :P states , regex or fixed index locations (ex SubString)
TextString.Split("blabla ")(0)
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
It's C# instead of VB and I'm sure there's a shorter way to code this, but I don't feel like putting forth the effort to clean it up right now.



[Image: BWFjx7k.png]
(Sep 3, 2017 09:07 PM)Shikatanai Wrote:  As title said, I need a help about it

Text:
Code
this text1
this text11
this text11
this text11

blabla

this text2

My code:
Code
Dim lines As New List(Of String)
        lines = txt1.Lines.ToList
        Dim FilterText = "(blabla )"

        For i As Integer = lines.Count - 1 To 0 Step -1
            If Regex.IsMatch(lines(i), FilterText) Then
                For u As Integer = lines.Count - 1 To lines(i) Step -1
                    lines.RemoveAt(u)
                Next
            End If
        Next
txt1.Lines = lines.ToArray

I want to delete line (blabla) until last line (this text2), but have a error in this part For u As Integer = lines.Count - 1 To lines(i) Step -1
Any help? thankyou

What error are you getting?
- Valeas quam optime. -
Code
For u As Integer = lines.Count - 1 To lines(i) Step -1

lines:
Code
Dim lines As New List(Of String)

syntax:
Code
For ? As {Type} = Min To Max (Step Increment)

The problem should be clear.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Sep 6, 2017 03:02 PM)0xDEAD10CC Wrote:  
Code
For u As Integer = lines.Count - 1 To lines(i) Step -1

His code didn't say that did it??
- Valeas quam optime. -
If you look at the first post...

[Image: vvtBnN0.png]

Or the post you quoted here: https://hackforums.net/showthread.php?ti...id55794306

It would have taken you a few seconds to verify it.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Sep 7, 2017 09:24 AM)0xDEAD10CC Wrote:  If you look at the first post...

[Image: vvtBnN0.png]

Or the post you quoted here: https://hackforums.net/showthread.php?ti...id55794306

It would have taken you a few seconds to verify it.

I'm fcking confused man. I look at all references and still don't see it like that. Oh well, I agree with your point though that wouldn't work lol.

EDIT: Oh fuck what a complete dick. I need more sleep. I see it now the second loop... what a fucking jerk my brain is.
- Valeas quam optime. -


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Formula 1Dec 6, 2019 01:11 AM 23 708 Dec 6, 2019 01:11 AM
Last Post: itcorp
[.NET] by HardStoNJan 31, 2019 12:05 AM 5 303 Jan 31, 2019 12:05 AM
Last Post: 0xDEAD10CC
[Java] by RaitzNov 4, 2017 02:04 PM 7 183 Nov 4, 2017 02:04 PM
Last Post: ZeratulTheWizard