저희 회사는... 경매를 처음 접하셔도 의뢰시 아주 쉽게 이해할 수 있도록 도움을 드리고. 낙찰받을 수 있는 유리한 조건을 쉽게 제시해 드립니다. 경매 컨설팅은 무엇보다 믿고 맡길 수 있는 회사와 함께 하셔야 낙찰 후 부동산 인도받는 날까지 걱정하나 없이 쉽고 신속하게 인도 받으실 수 있습니다. 최저 수수료를 약속드리며 추가 비용 없이 입주까지 일괄 책임지고 있습니다.
Imports System.Net.NetworkInformation
Imports System.Text
Imports System.Threading
Public Class Form1
' Ping 테스트 실행 여부를 저장하는 변수
Dim continuePing As Boolean = False
Dim pingThread As Thread ' Ping을 실행할 스레드
' 프로그램 로드 시 실행되는 이벤트 핸들러
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RadioButton4.Checked = True ' 기본 핑 간격을 1000ms로 설정
AddHandler CheckBox1.CheckedChanged, AddressOf CheckBox1_CheckedChanged ' CheckBox1 이벤트 핸들러 추가
End Sub
' 핑 테스트 시작 버튼 클릭 시 실행
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Not continuePing Then
continuePing = True
pingThread = New Thread(AddressOf PingTest) ' 별도 스레드에서 PingTest 실행
pingThread.IsBackground = True ' 백그라운드 스레드로 실행
pingThread.Start()
End If
End Sub
' 핑 테스트 중지 버튼 클릭 시 실행
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
continuePing = False
End Sub
' 마지막으로 저장된 파일 경로를 저장하는 변수
Private lastSavedFilePath As String = String.Empty
' Ping 테스트를 수행하는 함수
Private Sub PingTest()
Dim pingSender As New Ping()
Dim options As New PingOptions() With {.DontFragment = True} ' 패킷 분할 방지 옵션 설정
Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ' 핑에 포함될 데이터
Dim buffer As Byte() = Encoding.ASCII.GetBytes(data)
Dim timeout As Integer = 120 ' 응답 대기 시간(ms)
Dim reply As PingReply
' 핑 요청을 반복 실행
While continuePing
Dim targetHost As String = String.Empty
Invoke(Sub() targetHost = RichTextBox1.Text) ' UI 스레드에서 RichTextBox1의 값 가져오기
Try
reply = pingSender.Send(targetHost, timeout, buffer, options) ' 핑 요청 실행
Dim result As String
If reply.Status = IPStatus.Success Then
result = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} : {reply.Address}, 응답, 바이트={reply.Buffer.Length}, 시간={reply.RoundtripTime}ms, TTL={reply.Options.Ttl}"
Else
result = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} : {targetHost}, 응답 없음"
End If
' UI 스레드에서 ListBox1에 결과 추가 및 스크롤
Invoke(Sub()
ListBox1.Items.Add(result)
ListBox1.TopIndex = ListBox1.Items.Count - 1
CheckAndSaveListBox() ' 리스트가 일정 개수 이상이면 자동 저장
End Sub)
Catch ex As Exception
' 예외 발생 시 UI에 오류 메시지 출력
Invoke(Sub()
ListBox1.Items.Add("Ping 요청 실패: " & ex.Message)
ListBox1.TopIndex = ListBox1.Items.Count - 1
CheckAndSaveListBox()
End Sub)
End Try
Thread.Sleep(GetPingInterval()) ' 핑 간격만큼 대기
End While
End Sub
' 선택된 핑 간격 값을 반환하는 함수
Private Function GetPingInterval() As Integer
If RadioButton1.Checked Then Return 100
If RadioButton2.Checked Then Return 200
If RadioButton3.Checked Then Return 500
If RadioButton4.Checked Then Return 1000
If RadioButton5.Checked Then Return 1500
If RadioButton6.Checked Then Return 2000
Return 500 ' 기본값
End Function
' 프로그램 종료 버튼 클릭 시 실행
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
End
End Sub
' ListBox1에서 Ctrl+C로 항목 복사 가능하도록 설정
Private Sub ListBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles ListBox1.KeyDown
If e.Control AndAlso e.KeyCode = Keys.C Then
CopySelectedItemToClipboard()
End If
End Sub
' 선택한 항목을 클립보드에 복사하는 함수
Private Sub CopySelectedItemToClipboard()
If ListBox1.SelectedItem IsNot Nothing Then
Clipboard.SetText(ListBox1.SelectedItem.ToString())
End If
End Sub
' ListBox1의 내용을 지우는 버튼
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ListBox1.Items.Clear()
End Sub
' 핑 결과를 파일로 저장하는 버튼
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim saveFileDialog As New SaveFileDialog() With {
.FileName = "PingResults.txt",
.Filter = "텍스트 파일 (*.txt)|*.txt|모든 파일 (*.*)|*.*"
}
If saveFileDialog.ShowDialog() = DialogResult.OK Then
Using writer As New IO.StreamWriter(saveFileDialog.FileName)
For Each item As Object In ListBox1.Items
writer.WriteLine(item.ToString())
Next
End Using
End If
End Sub
' 프로그램 생성자
Public Sub New()
InitializeComponent()
LinkLabel1.Text = "만든놈 블로그"
LinkLabel1.Links.Add(0, 10, "https://blog.naver.com/php44")
AddHandler LinkLabel1.LinkClicked, AddressOf LinkLabel1_LinkClicked
End Sub
' 블로그 링크 클릭 시 웹 브라우저에서 열기
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs)
System.Diagnostics.Process.Start(e.Link.LinkData.ToString())
End Sub
' CheckBox1 체크 여부에 따라 창을 항상 위에 표시
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
Me.TopMost = CheckBox1.Checked
End Sub
' ListBox 항목이 200개 이상이면 자동 저장 후 초기화하는 함수
Private Sub CheckAndSaveListBox()
If ListBox1.Items.Count >= 200 Then
Dim timestamp As String = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")
Dim fileName As String = $"{timestamp}.txt"
Using writer As New IO.StreamWriter(fileName)
For Each item As Object In ListBox1.Items
writer.WriteLine(item.ToString())
Next
End Using
lastSavedFilePath = IO.Path.GetFullPath(fileName)
ListBox1.Items.Clear()
End If
End Sub
' 저장된 파일 경로 열기 버튼
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If Not String.IsNullOrEmpty(lastSavedFilePath) AndAlso IO.File.Exists(lastSavedFilePath) Then
Dim folderPath As String = IO.Path.GetDirectoryName(lastSavedFilePath)
System.Diagnostics.Process.Start("explorer.exe", folderPath)
Else
MessageBox.Show("저장된 파일이 없습니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
End Class