Click here to Skip to main content
15,440,771 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: combine two datatable Pin
Member 143292665-Jan-22 15:16
MemberMember 143292665-Jan-22 15:16 
AnswerRe: combine two datatable Pin
Raphael Adeniji7-May-22 5:09
MemberRaphael Adeniji7-May-22 5:09 
QuestionFind the 4th Tue of the Month when the Year changes Pin
Choroid30-Dec-21 8:41
MemberChoroid30-Dec-21 8:41 
AnswerRe: Find the 4th Tue of the Month when the Year changes Pin
Gerry Schmitz30-Dec-21 9:37
mveGerry Schmitz30-Dec-21 9:37 
GeneralRe: Find the 4th Tue of the Month when the Year changes Pin
Choroid30-Dec-21 10:30
MemberChoroid30-Dec-21 10:30 
AnswerRe: Find the 4th Tue of the Month when the Year changes Pin
Thava Rajan31-Dec-21 14:13
professionalThava Rajan31-Dec-21 14:13 
GeneralRe: Find the 4th Tue of the Month when the Year changes Pin
Choroid1-Jan-22 2:18
MemberChoroid1-Jan-22 2:18 
QuestionI need help. how do i code it??? Pin
Member 1548021627-Dec-21 15:33
MemberMember 1548021627-Dec-21 15:33 
hi i'm VB.net Newbi in south korea. it's difficult to me ;( .
I am creating a UDP chat by looking at the data. The server cannot send a message to the client. I need help. how do i code it??

-Send-
Shrink ▲   Copy Code
Imports System.IO
Imports System.Net.Sockets.Socket
Imports System
Imports System.Text
Imports System.Net
Imports System.Net.Sockets
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim GLOIP As IPAddress
    Dim GLOINTPORT As Integer
    Dim bytCommand As Byte() = New Byte() {}
    Dim udpClient As New UdpClient

    Public receivingUdpClient As UdpClient
    Public RemoteIpEndPoint As New System.Net.IPEndPoint(System.Net.IPAddress.Any, 0)

    Public ThreadReceive As System.Threading.Thread
    Dim SocketNO As Integer

    Private Sub cmdSend_Click(sender As Object, e As EventArgs) Handles cmdSend.Click
        Dim pRet As Integer

        Try

            'Get IP address
            GLOIP = IPAddress.Parse(txtIP.Text)
            'Get Port
            GLOINTPORT = txtPort.Text
            'Connect
            udpClient.Connect(GLOIP, GLOINTPORT)
            'Get Message from text box, encode it
            bytCommand = Encoding.Unicode.GetBytes(txtMessage.Text)
            'Send
            pRet = udpClient.Send(bytCommand, bytCommand.Length)

            txtInfo.Text = txtInfo.Text + vbCrLf + "The messege send is """
            txtInfo.Text = txtInfo.Text & Encoding.Unicode.GetString(bytCommand) & """"


        Catch ex As Exception

            txtInfo.Text = txtInfo.Text & vbCrLf & ex.Message
        End Try
    End Sub

    'txtMessage창에서 Enter키를 누르면 메시지를 전송하는 기능
    Private Sub txtMessage_KeyDown(sender As Object, e As KeyEventArgs) Handles txtMessage.KeyDown
        If e.KeyCode = Keys.Enter Then
            cmdSend.PerformClick()
            txtMessage.Clear()
        End If
    End Sub


End Class


--Receive--
Shrink ▲   Copy Code
Imports System.IO
Imports System
Imports System.Text
Imports System.Net
Imports System.Net.Sockets
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Public Class Form1
    Inherits System.Windows.Forms.Form
    Public receivingUdpClient As UdpClient
    Public RemoteIpEndPoint As New System.Net.IPEndPoint(System.Net.IPAddress.Broadcast, 0)
    Public ThreadReceive As System.Threading.Thread
    Dim SocketNO As Integer
    Public Delegate Sub SettheText(ByVal TextObject As TextBox, ByVal text As String)


    Public Sub setText(ByVal textobject As TextBox, ByVal text As String)
        Try
            If textobject.InvokeRequired Then
                Dim d As New SettheText(AddressOf setText)
                textobject.Invoke(d, New Object() {textobject, text})
            Else
                textobject.Text = text
            End If
        Catch ex As Exception
        End Try
    End Sub


    Public Sub ReceiveMessages()
        Try
            Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)
            'txtIP.Text = RemoteIpEndPoint.Address.ToString
            setText(txtIP, RemoteIpEndPoint.Address.ToString)
            txtInformation.Text = txtInformation.Text & vbCrLf & "A message is received and being processed"
            txtInformation.Text = txtInformation.Text + vbCrLf + "The message received is """
            txtInformation.Text = txtInformation.Text & Encoding.Unicode.GetString(receiveBytes) + """"
            txtInformation.Text = txtInformation.Text & vbCrLf

            NewInitialize()
        Catch e As Exception

        End Try
    End Sub
    Public Sub NewInitialize()

        ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
        ThreadReceive.Start()
    End Sub

    ' Clear 버튼을 누르면 TextBox 초기화
    Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click
        txtInformation.Text = "Information"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        Try
            SocketNO = txtSocket.Text
            receivingUdpClient = New System.Net.Sockets.UdpClient(SocketNO)
            ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
            ThreadReceive.Start()
            txtInformation.Text = "Connect Complete"
            txtInformation.Enabled = True
            btnStop.Enabled = True
            btnStart.Enabled = False
            txtSocket.ReadOnly = True
        Catch x As Exception

            txtInformation.Text = txtInformation.Text & vbCrLf & x.Message
        End Try
    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Try
            receivingUdpClient.Close()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        Try
            ThreadReceive.Abort()
            receivingUdpClient.Close()
            txtInformation.Text = "INFORMATION"
            txtInformation.Enabled = False
            btnStop.Enabled = False
            btnStart.Enabled = True
            txtIP.Text = ""
            txtSocket.ReadOnly = False
        Catch ex As Exception
            txtInformation.Text = txtInformation.Text & vbCrLf & ex.Message
        End Try
    End Sub

End Class
VB


AnswerRe: I need help. how do i code it??? Pin
Richard MacCutchan27-Dec-21 21:46
mveRichard MacCutchan27-Dec-21 21:46 
QuestionHow to display actual values on a chart using the Mouse_Move event. Pin
zomalaja25-Dec-21 13:10
Memberzomalaja25-Dec-21 13:10 
QuestionHow to BitConverter.GetBytes() return 2 digits only Pin
EngrImad3-Dec-21 23:39
MemberEngrImad3-Dec-21 23:39 
GeneralRe: How to BitConverter.GetBytes() return 2 digits only Pin
Richard MacCutchan4-Dec-21 0:18
mveRichard MacCutchan4-Dec-21 0:18 
AnswerRe: How to BitConverter.GetBytes() return 2 digits only Pin
EngrImad4-Dec-21 1:54
MemberEngrImad4-Dec-21 1:54 
AnswerRe: How to BitConverter.GetBytes() return 2 digits only Pin
Dave Kreskowiak4-Dec-21 3:43
mveDave Kreskowiak4-Dec-21 3:43 
Questionerror 50003 in vb6 in win 10 Pin
Member 110192491-Dec-21 0:10
MemberMember 110192491-Dec-21 0:10 
AnswerRe: error 50003 in vb6 in win 10 Pin
jsc421-Dec-21 0:26
professionaljsc421-Dec-21 0:26 
AnswerRe: error 50003 in vb6 in win 10 Pin
Richard Deeming1-Dec-21 1:08
mveRichard Deeming1-Dec-21 1:08 
QuestionHi How can i print listview with database im using phpmyadmin xampp Pin
Kyooshi29-Nov-21 19:54
MemberKyooshi29-Nov-21 19:54 
AnswerRe: Hi How can i print listview with database im using phpmyadmin xampp Pin
Richard Deeming29-Nov-21 21:47
mveRichard Deeming29-Nov-21 21:47 
AnswerRe: Hi How can i print listview with database im using phpmyadmin xampp Pin
Richard MacCutchan29-Nov-21 21:56
mveRichard MacCutchan29-Nov-21 21:56 
Questionface identification and recognition with visual Basic 2010 Pin
Member 1535104216-Nov-21 23:20
MemberMember 1535104216-Nov-21 23:20 
AnswerRe: face identification and recognition with visual Basic 2010 Pin
Richard MacCutchan16-Nov-21 23:27
mveRichard MacCutchan16-Nov-21 23:27 
AnswerRe: face identification and recognition with visual Basic 2010 Pin
CHill6024-Nov-21 0:32
mveCHill6024-Nov-21 0:32 
QuestionHOW TO CODE A REFRESH BUTTON IN VB.NET FORM Pin
WAHID ASSOCIATES8-Nov-21 9:09
MemberWAHID ASSOCIATES8-Nov-21 9:09 
AnswerRe: HOW TO CODE A REFRESH BUTTON IN VB.NET FORM Pin
Member 153296138-Nov-21 10:39
MemberMember 153296138-Nov-21 10:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.