互聯網上有很多關於線程的頁面,但是我似乎無法控制它。線程問題(我不明白)
我有一個窗體,點擊一個按鈕,循環瀏覽一個文件並逐行讀取它。每行是不同FTP站點的登錄詳細信息。
當它讀取一行時,它將使用登錄詳細信息將一個變量Dim作爲名爲CallFTP的類的新實例。
然後使用名爲PerformFTP的CallFTP中的函數將Dim變量作爲新線程Dim。
PerformFTP返回一個字符串與FTP的結果,我想將它添加到窗體上的一個ListBox開始它的一切。
該按鈕的代碼是這樣......
Private Sub cmdRun_Click(sender As Object, e As EventArgs) Handles cmdRun.Click
For Each _FTPLine As String In Split(_FTPDetails, vbNewLine)
Dim _Active As Boolean = CBool(Split(_FTPLine, "|")(7))
If _Active Then
_CurNum += 1
_ID = Format(Now.Year, "0000") & Format(Now.Month, "00") & Format(Now.Day, "00") & Format(Now.Hour, "00") & Format(Now.Minute, "00") & Format(Now.Second, "00") & Format(Now.Millisecond, "000") & Format(_CurNum, "00000")
Dim _FTP As New CallFTP(_ID, Split(_FTPLine, "|")(0), Split(_FTPLine, "|")(1), Split(_FTPLine, "|")(2), Split(_FTPLine, "|")(3), Split(_FTPLine, "|")(4), Split(_FTPLine, "|")(5), Split(_FTPLine, "|")(6))
Dim _Thread = New Thread(New ThreadStart(AddressOf _FTP.PerformFTP))
With _Thread
.IsBackground = True
.Start()
End With
End If
Next _FTPLine
End Sub
類是如下(不完全,但你並不需要的代碼的其餘部分笑)
Public Class CallFTP
Private _ID As String = ""
Private _Response As String = ""
Private _IPAddress As String = ""
Private _Port As String = ""
Private _User As String = ""
Private _Pass As String = ""
Private _Remote As String = ""
Private _Local As String = ""
Private _InOut As String = ""
Public Sub New(ID As String, Server As String, PortNum As String, Username As String, Password As String, RemoteDir As String, LocalDir As String, InOrOut As String)
_ID = ID
_IPAddress = Server
_Port = PortNum
_User = Username
_Pass = Password
_Remote = RemoteDir
_Local = LocalDir
_InOut = InOrOut
End Sub
Public Function PerformFTP() As String
Return "This is a test"
End Function
End Class
任何人都可以解釋我將如何調用一個名爲modMisc的模塊(它向主窗體上的ListBox添加一個字符串)上的子命名LogMessage?
我讀過,你需要調用它,但是我讀的所有東西似乎都讓我頭痛,讓我需要躺在黑暗的房間裏幾個小時。
任何人都可以解釋,就好像你正在說2歲? :)
任何幫助將不勝感激。
2歲的不要編程,幾乎不說話,你確定你想要那個對話框嗎? – OneFineDay
好吧,也許有點老。 Haha –
http://stackoverflow.com/q/8986810/1070452只是「RELATED」下列出的10個建議問題之一。雖然我沒有檢查「講話」級別。線程似乎有點多,順便說一句。 – Plutonix