Newsgroup: it.comp.lang.visual-basic
Titolo: [Principiante] Help !

Ciao a tutti,
Ho questo problema : Se ho messo in una variabile delle righe di testo
(prese da un file che ho letto riga per riga) , come faccio adesso ad
eliminare le ultime due righe ?
Grazie.

 ha scritto nel messaggio
news:cvedc.44843$rM4.1...@news4.tin.it...


Grazie Cristina !!!!!
Ciao.
"Cristina" <Pi...@Pika.it> ha scritto nel messaggio
news:oXedc.30405$hc5.1...@news3.tin.it...


 ha scritto

metti su un form un command e due txtbox con multiline=true e
scrollbar=vertical.
poi incolla il codice qui sotto
ciao, j.
Option Explicit
Private Sub Command1_Click()
    Dim a() As String, j As Long
    a = Split(Text1, vbNewLine)
    For j = LBound(a) To UBound(a) - 2
        Text2 = Text2 & a(j) & vbNewLine
    Next
End Sub
Private Sub Form_Load()
Text1 = Text1 & "Once a jolly swagman camped by a billabong," & vbNewLine
Text1 = Text1 & "Under the shade of a coolibah-tree," & vbNewLine
Text1 = Text1 & "And he sang as he watched and waited till his billy
boiled," & vbNewLine
Text1 = Text1 & "Who'll come a-waltzing Matilda with me?" & vbNewLine
Text1 = Text1 & "Waltzing Matilda, Waltzing Matilda," & vbNewLine
Text1 = Text1 & "Who 'll come a-waltzing Matilda with me?" & vbNewLine
Text1 = Text1 & "And he sang as he watched and waited till his billy
boiled," & vbNewLine
Text1 = Text1 & "Who'll come a-waltzing Matilda with me?" & vbNewLine
Text1 = Text1 & vbNewLine
Text1 = Text1 & "Down came a jumbuck to drink at the billabong:" & vbNewLine
Text1 = Text1 & "Up jumped the swagman and grabbed him with glee." &
vbNewLine
Text1 = Text1 & "And he sang as he shoved that jumbuck in his tucker-bag," &
vbNewLine
Text1 = Text1 & "You'll come a-waltzing Matilda with me." & vbNewLine
Text1 = Text1 & "Waltzing Matilda, Waltzing Matilda," & vbNewLine
Text1 = Text1 & "You 'll come a-waltzing Matilda with me." & vbNewLine
Text1 = Text1 & "And he sang as he shoved that jumbuck in his tucker-bag," &
vbNewLine
Text1 = Text1 & "You'll come a-waltzing Matilda with me." & vbNewLine
Text1 = Text1 & vbNewLine
Text1 = Text1 & "Up rode a squatter, mounted on his thoroughbred;" &
vbNewLine
Text1 = Text1 & "Down came the troopers, one, two, three:" & vbNewLine
Text1 = Text1 & "Who's that jolly jumbuck you've got in your tucker-bag?" &
vbNewLine
Text1 = Text1 & "You 'll come a-waltzing Matilda with me!" & vbNewLine
Text1 = Text1 & "Waltzing Matilda, Waltzing Matilda," & vbNewLine
Text1 = Text1 & "You 'll come a-waltzing Matilda with me." & vbNewLine
Text1 = Text1 & "Who 's that jolly jumbuck you've got in your tucker-bag?" &
vbNewLine
Text1 = Text1 & "You 'll come a-waltzing Matilda with me!" & vbNewLine
Text1 = Text1 & vbNewLine
Text1 = Text1 & "Up jumped the swagman and sprang into the billabong;" &
vbNewLine
Text1 = Text1 & "You'll never catch me alive! said he;" & vbNewLine
Text1 = Text1 & "And his ghost may be heard as you pass by that billabong,"
& vbNewLine
Text1 = Text1 & "You'll come a-waltzing Matilda with me!" & vbNewLine
Text1 = Text1 & "Waltzing Matilda, Waltzing Matilda," & vbNewLine
Text1 = Text1 & "You 'll come a-waltzing Matilda with me!" & vbNewLine
Text1 = Text1 & "And his ghost may be heard as you pass by that billabong,"
& vbNewLine
Text1 = Text1 & "You'll come a-waltzing Matilda with me!"
End Sub

 ha scritto nel messaggio
news:c5412o$2p19e9$1...@ID-51318.news.uni-berlin.de...


[Inesperto = 
circa...@posta.it
 in cvedc.44843$
rM4.1...@news4.tin.it
]
ha scritto:

Come hai letto le righe? Se con Line Input # non ti sono stati restituiti i
CrLf finali, quindi non hai un separatore di riga e sarebbe dura... Comunque
simulando di averli (anche quello dopo l'ultima riga):
    stringa = "1A" & vbCrLf & "2B" & vbCrLf & "3C" & vbCrLf & "4D" & vbCrLf
    righe_da_togliere = 2
    For n = 1 To righe_da_togliere
        stringa = Left(stringa, InStrRev(stringa, vbCrLf) - 1)
    Next n
    stringa = Left(stringa, InStrRev(stringa, vbCrLf) + (Len(vbCrLf) - 1))
.