首页> 疑难解答
这会更短吗?
withpy
2021-06-19
简介这段代码太长了。如何缩短它?非常3中3,这将出现在最后。 TxtDrawRemize.Text&= TxtResultStr1.Text +“”+ TxtResultStr2.Text +“”+ TxtResultStr3.Text&...
这段代码太长了。如何缩短它?非常3中3,这将出现在最后。 TxtDrawRemize.Text & = TxtResultStr1.Text + "" + TxtResultStr2.Text + "" + TxtResultStr3.Text & Environment.NewLine
我想这么做,我陷入了代码中,因为它太长了,有时候我会误解变量。如果你能帮助我,我将不胜感激。
Private Sub ScanareLinia1()
On Error Resume Next
Dim textsrtring As String = TxtStringNum1.Text
Dim words As String() = textsrtring.Split(" "c)
' Split string based on space
Dim found As Boolean = False
' Use For Each loop over words
Dim word As Integer
For Each word In words
For i As Integer = 0 To TxtIntDraws.Lines.Count - 1
If TxtIntDraws.Lines(1).Contains(word) Then
If Array.IndexOf(TxtIntDraws.Lines(1).Split(","c), CStr(word)) > -1 Then
TxtResultStr1.Text = word
End If
End If
Next
Next
End Sub
Private Sub ScanareLinia2()
On Error Resume Next
Dim textsrtring As String = TxtStringNum2.Text
Dim words As String() = textsrtring.Split(New Char() {" "c})
' Split string based on space
Dim found As Boolean = False
' Use For Each loop over words
Dim word As Integer
For Each word In words
For i As Integer = 0 To TxtIntDraws.Lines.Count - 1
If TxtIntDraws.Lines(1).Contains(word) Then
If Array.IndexOf(TxtIntDraws.Lines(1).Split(","c), CStr(word)) > -1 Then
TxtResultStr2.Text = word
End If
End If
Next
Next
End Sub
Private Sub ScanareLinia3()
On Error Resume Next
Dim textsrtring As String = TxtStringNum3.Text
Dim words As String() = textsrtring.Split(New Char() {" "c})
' Split string based on space
Dim found As Boolean = False
' Use For Each loop over words
Dim word As Integer
For Each word In words
For i As Integer = 0 To TxtIntDraws.Lines.Count - 1
If TxtIntDraws.Lines(1).Contains(word) Then
If Array.IndexOf(TxtIntDraws.Lines(1).Split(","c), CStr(word)) > -1 Then
TxtResultStr3.Text = word
End If
End If
Next
Next
TxtDrawRemize.Text &= TxtResultStr1.Text + " " + TxtResultStr2.Text + " " + TxtResultStr3.Text & Environment.NewLine
End Sub
Private Sub ScanareLinia4()
On Error Resume Next
Dim textsrtring As String = TxtStringNum1.Text
Dim words As String() = textsrtring.Split(New Char() {" "c})
' Split string based on space
Dim found As Boolean = False
' Use For Each loop over words
Dim word As Integer
For Each word In words
For i As Integer = 0 To TxtIntDraws.Lines.Count - 1
If Array.IndexOf(TxtIntDraws.Lines(2).Split(","c), CStr(word)) > -1 Then
TxtResultStr1.Text = word
End If
Next
Next
End Sub
Private Sub ScanareLinia5()
On Error Resume Next
Dim textsrtring As String = TxtStringNum2.Text
Dim words As String() = textsrtring.Split(New Char() {" "c})
' Split string based on space
Dim found As Boolean = False
' Use For Each loop over words
Dim word As Integer
For Each word In words
For i As Integer = 0 To TxtIntDraws.Lines.Count - 1
If Array.IndexOf(TxtIntDraws.Lines(2).Split(","c), CStr(word)) > -1 Then
TxtResultStr2.Text = word
End If
Next
Next
End Sub
Private Sub ScanareLinia6()
On Error Resume Next
Dim textsrtring As String = TxtStringNum3.Text
Dim words As String() = textsrtring.Split(New Char() {" "c})
' Split string based on space
Dim found As Boolean = False
' Use For Each loop over words
Dim word As Integer
For Each word In words
For i As Integer = 0 To TxtIntDraws.Lines.Count - 1
If Array.IndexOf(TxtIntDraws.Lines(2).Split(","c), CStr(word)) > -1 Then
TxtResultStr3.Text = word
End If
Next
Next
TxtDrawRemize.Text &= TxtResultStr1.Text + " " + TxtResultStr2.Text + " " + TxtResultStr3.Text & Environment.NewLine
End Sub
相关文章
-
如何结合dplyr mutate和case_when函数使用lubridate as_datetime函数?
我试图操纵一个dttm变量来根据数字id向量调整不同的时区。我可以根据id操纵变量而不会出现使用字符向量的问题......
-
无法读取android调试密钥
尝试构建我的应用程序,我可以在10分钟前没有任何问题构建,并突然开始出现此错误:*出了什么问题:执行失败的任务':app:packageDebug'。 >失败了......
-
如何隐藏网站上的Google Chrome状态栏
我注意到了Progressive Web Apps(PWA)的发展趋势,所以我试图了解它们的全部内容。在大多数PWA中,我看到隐藏了浏览器镶边(URL栏,后退按钮,...
-
SQL Update触发器未按预期工作
我的oracle表上有一个更新触发器..但似乎它不起作用。创建触发器和表的模式是HR创建或替换触发器TR_FinlStatAssetDesignation_U之前...
-
Android服务始终不活跃
我使用报警服务永远启动服务,但这不是一个解决方案,有时停止工作......所以运行服务的最佳方式是什么,总是像WhatsApp?
-
PDFBox - 将2张肖像页面合并到一个并排的横向页面上
我正在尝试编写一个pdf转换,它将采用包含1-up肖像页面的pdf,并创建一个新文档,但每2页合并为一个2-up格局页面,即。以下代码......