This site is developed to XHTML and CSS2 W3C standards.
If you see this paragraph, your browser does not support those standards and you
need to upgrade. Visit WaSP
for a variety of options.
Paste #605
Posted by:
Posted on: 2026-02-28 22:04:57
Age: 1 day ago
Views: 7
Option Explicit
' ===== ЗАГРУЗКА ФОРМЫ =====
' ===== ЗАГРУЗКА ФОРМЫ =====
Private Sub Form_Load()
Dim confName As String
Dim serverName As String
' Загружаем данные из файла
LoadConferenceData confName, serverName
' Если сервер не был загружен из файла, ставим "general"
If Trim(serverName) = "" Then
serverName = "general"
End If
txtConferenceName.Text = confName
txtServerName.Text = serverName
End Sub
' ===== КНОПКА OK =====
Private Sub cmdOK_Click()
If Trim(txtConferenceName.Text) = "" Then
MsgBox "Please enter the conference name.", vbExclamation
Exit Sub
End If
' ==== Сохраняем введённые данные в файл ====
SaveConferenceData Trim(txtConferenceName.Text), Trim(txtServerName.Text)
' ==== Сохраняем адрес конференции в переменную ДО Unload Me ====
Dim confAddr As String
If Trim(txtServerName.Text) = "" Then
confAddr = Trim(txtConferenceName.Text)
Else
confAddr = Trim(txtConferenceName.Text) & "@" & Trim(txtServerName.Text)
End If
' ==== Формируем команду /join_server ====
Dim joinCmd As String
joinCmd = "/join_server " & confAddr
' ==== Закрываем форму JoinConference сразу ====
Unload Me
' ==== Проверка: уже подключены к конференции ====
If Not Form1.ServerChatWindow Is Nothing Then
If Form1.ServerChatWindow.Visible = True Then
MsgBox "You are already connected to a conference." & vbCrLf & _
"If you want to join another one," & vbCrLf & _
"please close the current conference window first.", _
vbExclamation, "Conference already opened"
Exit Sub
End If
End If
' ==== Создаём новое серверное окно ====
Set Form1.ServerChatWindow = New FormChat
Form1.ServerChatWindow.SetServer confAddr
Form1.ServerChatWindow.Show vbModeless
' ==== Отправляем команду на сервер ====
Form1.SendMessageToUser "", joinCmd
End Sub
' ===== КНОПКА CANCEL =====
Private Sub cmdCancel_Click()
Unload Me
End Sub
' ===== СОХРАНЕНИЕ ДАННЫХ В conference.dat =====
Private Sub SaveConferenceData(ByVal confName As String, ByVal serverName As String)
Dim f As Integer
f = FreeFile
Open App.Path & "\conference.dat" For Output As #f
Print #f, confName
' Если серверное поле пустое, сохраняем "general"
If Trim(serverName) = "" Then serverName = "general"
Print #f, serverName
Close #f
End Sub
' ===== ЗАГРУЗКА ДАННЫХ ИЗ conference.dat =====
Private Sub LoadConferenceData(ByRef confName As String, ByRef serverName As String)
Dim f As Integer
If Dir(App.Path & "\conference.dat") = "" Then
confName = ""
serverName = "" ' оставляем пустым, потом заменим на "general"
Exit Sub
End If
f = FreeFile
Open App.Path & "\conference.dat" For Input As #f
Line Input #f, confName
Line Input #f, serverName
Close #f
End Sub
' ===== ENTER = OK =====
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
KeyCode = 0
cmdOK_Click
End If
End Sub
Download raw |
Create new paste