vb中如何删除text中指定行的数据
展开全部
Private Sub Command1_Click()
For i = 1 To 20
Text1 = Text1 & vbCrLf & i + 213
Next i
End Sub
Private Sub Command2_Click()
k = Val(InputBox("请输入你要删除的行:"))
On Error Resume Next
a = 1
For i = 1 To Val(k) - 1
a = InStr(a + 1, Text1.Text, vbCrLf)
Next i
wz2 = InStr(a + 1, Text1.Text, vbCrLf)
If i = 1 Then
Text1 = Mid(Text1, wz2 + 1)
ElseIf wz2 > 0 Then
Text1.Text = Mid(Text1, 1, a - 1) & Mid(Text1, wz2)
Else
Text1.Text = Mid(Text1, 1, a - 1)
End If
End Sub
For i = 1 To 20
Text1 = Text1 & vbCrLf & i + 213
Next i
End Sub
Private Sub Command2_Click()
k = Val(InputBox("请输入你要删除的行:"))
On Error Resume Next
a = 1
For i = 1 To Val(k) - 1
a = InStr(a + 1, Text1.Text, vbCrLf)
Next i
wz2 = InStr(a + 1, Text1.Text, vbCrLf)
If i = 1 Then
Text1 = Mid(Text1, wz2 + 1)
ElseIf wz2 > 0 Then
Text1.Text = Mid(Text1, 1, a - 1) & Mid(Text1, wz2)
Else
Text1.Text = Mid(Text1, 1, a - 1)
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
For i = 1 To 20
Text1 = Text1 & vbCrLf & i + 213
Next i
End Sub
Private Sub Command2_Click()
k = Val(InputBox("请输入你要删除的行:"))
On Error Resume Next
a = 1
For i = 1 To Val(k) - 1
a = InStr(a + 1, Text1.Text, vbCrLf)
Next i
wz2 = InStr(a + 1, Text1.Text, vbCrLf)
If i = 1 Then
Text1 = Mid(Text1, wz2 + 1)
ElseIf wz2 > 0 Then
Text1.Text = Mid(Text1, 1, a - 1) & Mid(Text1, wz2)
Else
Text1.Text = Mid(Text1, 1, a - 1)
End If
End Sub
For i = 1 To 20
Text1 = Text1 & vbCrLf & i + 213
Next i
End Sub
Private Sub Command2_Click()
k = Val(InputBox("请输入你要删除的行:"))
On Error Resume Next
a = 1
For i = 1 To Val(k) - 1
a = InStr(a + 1, Text1.Text, vbCrLf)
Next i
wz2 = InStr(a + 1, Text1.Text, vbCrLf)
If i = 1 Then
Text1 = Mid(Text1, wz2 + 1)
ElseIf wz2 > 0 Then
Text1.Text = Mid(Text1, 1, a - 1) & Mid(Text1, wz2)
Else
Text1.Text = Mid(Text1, 1, a - 1)
End If
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private sub command1_click()
dim d as integer,i as integer
dim t() as string
t=split(text1.text,vbcrlf)
d=val(inputbox("输入要删除的行号:"))
if d=0 or d>ubound(t)+1 then
msgbox "行号错误"
exit sub
end if
text1=""
for i=0 to ubound(t)
if i<>d-1 then
text1=text1 & t(i) & vbcrlf
end if
next i
end sub
dim d as integer,i as integer
dim t() as string
t=split(text1.text,vbcrlf)
d=val(inputbox("输入要删除的行号:"))
if d=0 or d>ubound(t)+1 then
msgbox "行号错误"
exit sub
end if
text1=""
for i=0 to ubound(t)
if i<>d-1 then
text1=text1 & t(i) & vbcrlf
end if
next i
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询