谁能把C#2003程序转成VB2005?
谁能把C#2003程序转成VB2005?我用转换工具转换后问题很多。谁能帮忙转换下啊,给分或者人民币都可以,有兴趣的可以联系我QQ 20309785
[解决办法]
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.SelectionLength = 0
Dim address As String = "192.168.1.1 "
Dim port As Int32 = Int32.Parse( "23 ")
Dim IPHost As IPHostEntry = Dns.GetHostEntry(address)
Dim aliases() As String = IPHost.Aliases
Dim addr() As IPAddress = IPHost.AddressList
Try
' Create New Socket
Dim s As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
' Create New EndPoint
Dim iep As New IPEndPoint(addr(0), port)
' This is a non blocking IO
s.Blocking = False
' Assign Callback function to read from Asyncronous Socket
Dim callbackProc As New AsyncCallback(ConnectCallback)
' Begin Asyncronous Connection
s.BeginConnect(iep, callbackProc, s)
Catch eeeee As Exception
MessageBox.Show(eeeee.Message, "Application Error!!! ", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Application.Exit()
End Try
End Sub
Public Sub ConnectCallback(ByVal ar As IAsyncResult)
Try
' Get The connection socket from the callback
Dim sock1 As Socket = CType(ar.AsyncState, Socket)
If sock1.Connected Then
' Define a new Callback to read the data
Dim recieveData As New AsyncCallback(OnRecievedData)
' Begin reading data asyncronously
sock1.BeginReceive(m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData, sock1)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Setup Recieve callbackProc failed! ")
End Try
End Sub
Public Sub OnRecievedData(ByVal ar As IAsyncResult)
' Get The connection socket from the callback
Dim sock As Socket = CType(ar.AsyncState, Socket)
' Get The data , if any
Dim nBytesRec As Int32 = sock.EndReceive(ar)
If (nBytesRec > 0) Then
Dim sRecieved As String = Encoding.ASCII.GetString(m_byBuff, 0, nBytesRec)
Dim m_strLine As String = " "
For i As Int32 = 0 To nBytesRec - 1
Dim ch As Char = Convert.ToChar(m_byBuff(i))
Select Case ch
Case "\r "
m_strLine += Convert.ToString( "\r\n ")
Case "\n "
Case Else
m_strLine += Convert.ToString(ch)
End Select
Next
'try
Dim strLinelen As Int32 = m_strLine.Length
If strLinelen = 0 Then
m_strLine = Convert.ToString( "\r\n ")
End If
Dim mToProcess(strLinelen) As Byte
For i As Int32 = 0 To strLinelen - 1
mToProcess(i) = Convert.ToByte(m_strLine(i))
Next
' Process the incoming data
Dim mOutText As String = CType(mToProcess, ProcessOptions)
If (mOutText <> " ") Then
'下面这句有问题,线程间操作无效: 从不是创建控件“textBox1”的线程访问它。
TextBox1.AppendText(mOutText)
End If
' Respond to any incoming commands
RespondToOptions()
'catch( Exception ex )
'{
' Object x = this
' MessageBox.Show(ex.Message , "Information! " )
'}
Else
' If no data was recieved then the connection is probably dead
Console.WriteLine( "Disconnected ", sock.RemoteEndPoint)
sock.Shutdown(SocketShutdown.Both)
sock.Close()
Application.Exit()
End If
End Sub
End Class
[解决办法]
晕.我的是 vb-> c#的.帮不了你了.听说网上有个在线的网页可以转.但没用过.找找看吧.