Vb.net 我能';不要走下坡路

Vb.net 我能';不要走下坡路,vb.net,minecraft,Vb.net,Minecraft,我遵循了一个教程,制作了一个Minecraft服务器pinger,但我希望所有信息都在不同的行中,如下所示: Server online! The message of the day is ... There are 0/2 players 我的代码 Imports Wrapped Imports System.Net.Sockets Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, B

我遵循了一个教程,制作了一个Minecraft服务器pinger,但我希望所有信息都在不同的行中,如下所示:

Server online!
The message of the day is ...
There are 0/2 players
我的代码

Imports Wrapped
Imports System.Net.Sockets

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles    Button1.Click
    Label3.Text = PingServer(TextBox1.Text, TextBox2.Text)

End Sub
Private Function PingServer(ByVal IP As String, ByVal port As Integer)
    Dim MySocket As New TcpClient(IP, port)
    Dim Socket As New Wrapped.Wrapped(MySocket.GetStream)
    Socket.writeByte(254)
    Socket.writeByte(1)
    If Socket.readByte() = 255 Then
        Dim mystring As String = Socket.readString()
        Dim mysplit() As String = mystring.Split(ChrW(CByte(0)))
        Return "The server is online"
        Return Environment.NewLine & "The message of the day is " & mysplit(3)
        Return Environment.NewLine & "There are" & mysplit(4) & "/" & mysplit(5) & "players"
    Else


        Return "Something went wrong! Please try again."



    End If
    Return ""

End Function
End Class

Return关键字将向调用者返回执行。因此,当它第一次返回时,它将返回它旁边的内容,而不会返回其他内容。在您的情况下,您将只获得服务器处于联机状态的

您需要的是一个凝聚的字符串。有很多方法可以做到这一点,其中之一如下

    Return "The server is online" & _
    Environment.NewLine & "The message of the day is " & mysplit(3) & _
    Environment.NewLine & "There are" & mysplit(4) & "/" & mysplit(5) & "players"
请注意,您不必将它们放在不同的行中,但对于阅读代码更为有利