[.NET] 讀取檔案出錯

看板Visual_Basic作者 (澈)時間18年前 (2007/11/12 18:57), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
這是我的程式碼 Sub FileR() '讀取伺服器位置 If Not File.Exists("ServerIP") Then FileW() End If Using sr1 As StreamReader = New StreamReader("ServerIP") Dim line As String line = sr1.ReadLine SET_sock(line) While Not line Is Nothing Dim f As Integer = 1 Dim b As Integer = 1 Do While b <= 2 Console.WriteLine(line) Do line = sr1.ReadLine f = f + 1 Loop Until f > b SET_sock(line) b += 1 Loop End While End Using End Sub Sub SET_sock(ByVal ip As String) '設定封包目的 Using sr As StreamReader = New StreamReader("ServerIP") Select Case z Case 1 With AxWinsock1 .Protocol = MSWinsockLib.ProtocolConstants.sckUDPProtocol .RemoteHost = Mid(ip, 1, InStr(ip, ":") - 1) .RemotePort = Mid(ip, InStr(ip, ":") + 1, ip.Length - InStr(ip, ":")) .Bind() .SendData(TextBox1.Text) End With Case 2 With AxWinsock5 .Protocol = MSWinsockLib.ProtocolConstants.sckUDPProtocol .RemoteHost = Mid(ip, 1, InStr(ip, ":") - 1) .RemotePort = Mid(ip, InStr(ip, ":") + 1, ip.Length - InStr(ip, ":")) .Bind() .SendData(TextBox1.Text) End With Case 3 With AxWinsock6 .Protocol = MSWinsockLib.ProtocolConstants.sckUDPProtocol .RemoteHost = Mid(ip, 1, InStr(ip, ":") - 1) .RemotePort = Mid(ip, InStr(ip, ":") + 1, ip.Length - InStr(ip, ":")) .Bind() .SendData(TextBox1.Text) End Select End Using End Sub 我想要從檔案讀取server的ip跟port 然後Client的一個port依序從檔案抓取字串來送 可是我按送出之後 在 .Protocol = MSWinsockLib.ProtocolConstants.sckUDPProtocol 這段會出錯 想請問板上大大是哪裡寫錯了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.130.189.49
文章代碼(AID): #17E36851 (Visual_Basic)