R
Radek Budaø
Hi all,
i have trouble with changing text value of textbox on runtime. I use this
control to display process information about sending e-mail per smtp. I use
external component
which can hadle events by sending mail.
I have function, which can calculate status of process in percent
Progress Function is called every time, when sending status is changed,
function calculates correctly 'percent' value, but on form i cannot change
default text. Can you anybody help me? Below i attached all source code for
this form.
I have no onLoad Function for this form defined. Is it problem? How can I
changed text value of text box on runtime?
Than you for your help
Radek Budar
Imports System.Text
Imports devBiz.Net.Mail
Public Class frmRegistrationRequest
Dim frmMailStatusForm as New frmMailSendingStatus
Private Sub sendRequest( ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles btnSendRegReq.Click
Dim strPrijmeni as String
Dim strJmeno as String
Dim strMesto as String
Dim strEmail as String
Dim sql as String
Dim firstRun as Date
Dim regNrUser as Double
Dim mailMsg As MailMessage = New MailMessage
mailMsg.From.EMail = "(e-mail address removed)"
mailMsg.To.Add("XXX","(e-mail address removed)")
Dim now as Date
strPrijmeni = txtPrijmeni.Text
strJmeno = txtJmeno.Text
strMesto = txtMesto.Text
strEmail = txtEmail.Text
Dim sb As New StringBuilder()
sb.Append(strPrijmeni)
sb.Append(",")
sb.Append(strJmeno)
sb.Append(",")
sb.Append(strMesto)
sb.Append(",")
sb.Append(strEmail)
sb.Append(",")
sb.Append(regNrUser)
mailMsg.Subject = "test - " & now
mailMsg.Body = sb.ToString
Dim client As smtp = New smtp
client.Host = "smtp.seznam.cz"
client.Port = 25
' We will capture the progress event, so we attach an event handler
AddHandler client.OnProgress, AddressOf Progress
txtMailStatus.Visible = True
'E-mail sending
Try
client.SendMessage(mailMsg)
Catch ex As System.Net.Mail.SmtpException
txtMailStatus.ForeColor = Color.Red
txtMailStatus.Text = "Failure!"
MsgBox("Odeslání e-mailu se nezdaøilo, zkontrolujte pøipojení k internetu!"
& vbNewLine & vbNewLine + ex.Message, MsgBoxStyle.Exclamation, "Chyba pøi
odesílání registraèního e-mailu")
Exit Sub
Finally
End Try
txtMailStatus.ForeColor = Color.Green
txtMailStatus.text = "Done...success!"
stavRegistrace = 3
Me.Close
End Sub
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventArgs)
Dim percent As Integer = _
CType((CType(e.Position / e.Length * 100, Double)), Integer)
txtMailStatus.Text = percent
End Sub
End Class
i have trouble with changing text value of textbox on runtime. I use this
control to display process information about sending e-mail per smtp. I use
external component
which can hadle events by sending mail.
I have function, which can calculate status of process in percent
Progress Function is called every time, when sending status is changed,
function calculates correctly 'percent' value, but on form i cannot change
default text. Can you anybody help me? Below i attached all source code for
this form.
I have no onLoad Function for this form defined. Is it problem? How can I
changed text value of text box on runtime?
Than you for your help
Radek Budar
Imports System.Text
Imports devBiz.Net.Mail
Public Class frmRegistrationRequest
Dim frmMailStatusForm as New frmMailSendingStatus
Private Sub sendRequest( ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles btnSendRegReq.Click
Dim strPrijmeni as String
Dim strJmeno as String
Dim strMesto as String
Dim strEmail as String
Dim sql as String
Dim firstRun as Date
Dim regNrUser as Double
Dim mailMsg As MailMessage = New MailMessage
mailMsg.From.EMail = "(e-mail address removed)"
mailMsg.To.Add("XXX","(e-mail address removed)")
Dim now as Date
strPrijmeni = txtPrijmeni.Text
strJmeno = txtJmeno.Text
strMesto = txtMesto.Text
strEmail = txtEmail.Text
Dim sb As New StringBuilder()
sb.Append(strPrijmeni)
sb.Append(",")
sb.Append(strJmeno)
sb.Append(",")
sb.Append(strMesto)
sb.Append(",")
sb.Append(strEmail)
sb.Append(",")
sb.Append(regNrUser)
mailMsg.Subject = "test - " & now
mailMsg.Body = sb.ToString
Dim client As smtp = New smtp
client.Host = "smtp.seznam.cz"
client.Port = 25
' We will capture the progress event, so we attach an event handler
AddHandler client.OnProgress, AddressOf Progress
txtMailStatus.Visible = True
'E-mail sending
Try
client.SendMessage(mailMsg)
Catch ex As System.Net.Mail.SmtpException
txtMailStatus.ForeColor = Color.Red
txtMailStatus.Text = "Failure!"
MsgBox("Odeslání e-mailu se nezdaøilo, zkontrolujte pøipojení k internetu!"
& vbNewLine & vbNewLine + ex.Message, MsgBoxStyle.Exclamation, "Chyba pøi
odesílání registraèního e-mailu")
Exit Sub
Finally
End Try
txtMailStatus.ForeColor = Color.Green
txtMailStatus.text = "Done...success!"
stavRegistrace = 3
Me.Close
End Sub
Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventArgs)
Dim percent As Integer = _
CType((CType(e.Position / e.Length * 100, Double)), Integer)
txtMailStatus.Text = percent
End Sub
End Class