|
You're only about 15 years too late.
|
|
|
|
|
I have no idea how this forums works anymore, you responded and now spaghetti in my messagebox full of tutorials..........
But i know VB6 is out-of date, I'm a retro guy, and win9X compatibily is crucial in my case.... who knows if anyone might have something I can fit in the program. :/
|
|
|
|
|
|
Just did, spaghetti is gone, yay....
But uhm, so you are stating the language is dead and thsi is no use seeing the last Service Pack was in 1999?
|
|
|
|
|
It's like cars - most people would like a nice new car for reasons of comfort, performance and features, but some people like classic cars that can be temperamental and don't have many of the luxuries of modern design. There is nothing wrong with this, but if you are asked to provide a taxi service I would expect it to use modern cars with aircon and satnav, rather than a Morris Minor or Model T Ford.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I'm not sure what your question is.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Me or the ones talking about cars for some reason?
|
|
|
|
|
I think people are not entirely sure what you are asking.
Do you need code samples and such, or do you just want ideas on what sort of programs you could try to code using VB6 ?
If you want samples, you need to be more specific as to what of, and you need to show that you have made some sort of effort already yourself. Show some code that you have written that you want help with.
If you want ideas for programs to code in VB6, then you are not asking in the right place. On this forum you can get help realizing your coding goals, but very very little in determining what these goals should be.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ah, so in reply to the question if I need samples or ideas. I need code samples and other programs with source code...
I have made a little installer now for a beta test: Click Here[^]
It has no logo's yet, but is stable...
|
|
|
|
|
So stable it doesn't exist!
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
|
Oops, just noticed that the file expired... hehe :/
Here is a more recent build: Cick Here, again[^]
|
|
|
|
|
|
You seriously expect us to run an exe file from the web?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
How about a portable version instead of the NSIS installer. Portable
modified 3-Sep-16 7:27am.
|
|
|
|
|
Hello!
In my data entry form, all the fields are bound to a tblStaff table through BindingSource (staffInfoBS).
One of these controls is a cboGender ComboBox.
I want to manually populate the cboGender with only two items -- "Male" and "Female" and the SelectedValue be saved in the underlying table.
If I try to use something like Items.Insert, I receive error:
Items collection cannot be modified when the DataSource property is set.
How can get it done. Please suggest.
|
|
|
|
|
You either have to have items in the datasource that your combo seems to be bound to or you have to scrap the binding on the combo and put the items in yourself. You can't have both.
|
|
|
|
|
I'm having problems with sending email using CBeyond from all of my programs in VB.
So I decided to change my send function to SendAsync, and Async, and just send each message 1 at at a time and wait for the results so it can be logged when done. (Thus the SQLite Question earlier)
So I thought this would be pretty easy, just change SmtpClient.Send(mailMessage) to smtpClient.SendAsync(mailMessage, cancelToken), but I guess now I need to add a callback.
So I got some ideas from this link, and used some of the concepts.
The part I don't understand is calling the function, and setting the Public Event for the callback.
c# - Send email when using SmtpClient - Stack Overflow[^]
I c#, the code is this, but I have no clue what it is, it's beyond my c# skills.
var sender = new EmailSender();
sender.SendEmailCompleted += (o, eventArgs)
=> Console.WriteLine(eventArgs.RetryCount);
sender.SendEmailAsync(new MailMessage(), 5);
And I translated it using CodeTranslator CodeTranslator: Code Translation From VB.NET
I'm looking at it and I have no clue what it is, I only recognize the first and last lines.
Dim sender As var = New EmailSender
sender.SendEmailCompleted = (sender.SendEmailCompleted + o)
,eventArgs
Unknown=GreaterConsole.WriteLine(eventArgs.RetryCount)
sender.SendEmailAsync(New MailMessage, 5)
This is what I wrote from the C# example in the web page link. I'm pretty sure I got it right and updated some of the event handlers.
Imports System.ComponentModel
Imports System.Net.Mail
Public Class SendEngine
Private _currentRetryCount As Integer
Private _maxRetryCount As Integer
Private _mailMessage As MailMessage
Private _isAlreadyRun As Boolean
Public Event SendEmailCompleted As SendEmailCompletedEventHandler
Public Sub SendEmailAsync(ByVal smtpClient As SmtpClient, ByVal message As MailMessage, ByVal retryCount As Integer)
If _isAlreadyRun Then
Throw New InvalidOperationException("sendEngine doesn't support multiple concurrent invocations.")
End If
_isAlreadyRun = True
_maxRetryCount = retryCount
_mailMessage = message
AddHandler smtpClient.SendCompleted, AddressOf SmtpClientSendCompleted
SendMessage(smtpClient)
End Sub
Private Sub SendMessage(ByVal smtpClient As SmtpClient)
Try
smtpClient.SendAsync(_mailMessage, Guid.NewGuid)
Catch exception As Exception
EndProcessing(smtpClient)
End Try
End Sub
Private Sub EndProcessing(ByVal smtpClient As SmtpClient)
If (_mailMessage IsNot Nothing) Then
_mailMessage.Dispose()
End If
If (smtpClient IsNot Nothing) Then
RemoveHandler smtpClient.SendCompleted, AddressOf SmtpClientSendCompleted
smtpClient.Dispose()
End If
OnSendCompleted(New SendEmailCompletedEventArgs(Nothing, False, Nothing, _currentRetryCount))
_isAlreadyRun = False
_currentRetryCount = 0
End Sub
Private Sub SmtpClientSendCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
Dim smtpClient = CType(sender, SmtpClient)
If ((e.Error Is Nothing) OrElse (_currentRetryCount >= _maxRetryCount)) Then
EndProcessing(smtpClient)
Else
_currentRetryCount = (_currentRetryCount + 1)
SendMessage(smtpClient)
End If
End Sub
Protected Overridable Sub OnSendCompleted(ByVal args As SendEmailCompletedEventArgs)
RaiseEvent SendEmailCompleted(Me, args)
End Sub
End Class
Public Delegate Sub SendEmailCompletedEventHandler(ByVal sender As Object, ByVal e As SendEmailCompletedEventArgs)
Public Class SendEmailCompletedEventArgs
Inherits AsyncCompletedEventArgs
Private mRetryCount As Integer
Public Sub New(ByVal ex As Exception, ByVal canceled As Boolean, ByVal userState As Object, ByVal retryCount As Integer)
MyBase.New(ex, canceled, userState)
retryCount = retryCount
End Sub
Public Property RetryCount As Integer
Get
Return mRetryCount
End Get
Set(value As Integer)
value = mRetryCount
End Set
End Property
End Class
modified 13-May-16 3:00am.
|
|
|
|
|
The code translator seems to have screwed up the event handler. The C# code:
sender.SendEmailCompleted += (o, eventArgs)
=> Console.WriteLine(eventArgs.RetryCount);
would translate as something like this:
AddHandler sender.SendEmailCompleted, Sub(ByVal sender As Object, ByVal e As SendEmailCompletedEventArgs)
Console.WriteLine(eventArgs.RetryCount)
End Sub
If you're using .NET 4.5 or later, I'd be inclined to use an Async[^] method, and use the SmtpClient.SendMailAsync method[^]:
Public Async Function SendEmailAsync(ByVal smtpClient As SmtpClient, ByVal message As MailMessage, ByVal retryCount As Integer) As Task(Of SendEmailCompletedEventArgs)
Dim currentTry As Integer = 0
While currentTry < retryCount
Try
Await smtpClient.SendMailAsync(message)
Return New SendEmailCompletedEventArgs(Nothing, False, Nothing, currentTry)
Catch exception As Exception
currentTry += 1
If currentTry >= retryCount Then
Return New SendEmailCompletedEventArgs(ex, True, Nothing, currentTry)
End If
End Try
End While
Return New SendEmailCompletedEventArgs(Nothing, True, Nothing, currentTry)
End Function
Your calling code can then use a Using block to clean up the SmtpClient and MailMessage instances:
Public Async Function SendAllMessages() As Task
Using smtpClient As SmtpClient = CreateSmtpClient()
For Each item As SomeType In SomeListOfData
Using message As MailMessage = CreateMessageFor(item)
Dim result As SendEmailCompletedEventArgs = Await SendEmailAsync(smtpClient, message, RetryCount)
ProcessSendResult(item, result)
End Using
Next
End Using
End Function
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I knew it was a handler with the +=, but had no idea it was a sub call, Thanks!
I was thinking last night how to handle the smtpclient with using so it can release it resources.
I have a dialog that loops the collection of jobs in a listview, that generates a PDF attachment and then composes the message via await. In the composer function, it calls the SendMessage which is not await. I need to rethink that. It's OK to await again?
I didn't want to pollute my composition function with the Send Function and separated them.
Well, I'll add the handler and give it a spin, and then work on using the smtpclient.
Thanks Richard! and Upvote
for each job in jobs
Await Compose
next
Function Compose()
Build Message
Attach PDF
Build smtpClient
Send
Log send error
End Function
Function Send
SendAsync
End Function
|
|
|
|
|
jkirkerx wrote: It's OK to await again?
Yes, awaiting from within an async method that's been awaited is perfectly fine.
You might want to add .ConfigureAwait(False) to the awaited expressions, where the remainder of the method doesn't need to execute in the same context:
Await smtpClient.SendMailAsync(message).ConfigureAwait(False)
Async/Await - Best Practices in Asynchronous Programming[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK, I understand.
Well, so far in code I got what I wanted out of it. I just need to log the error in the database so I can conclude that the email was sent to the Cbeyond mail servers, and it's out of my hands.
'This is the new sendEngine
Dim sE As New SendEngine()
sE.SendEmailAsync(smtpClient, mailMessage, 5)
AddHandler sE.SendEmailCompleted, _
Sub(sender As Object, e As SendEmailCompletedEventArgs)
Console.WriteLine(e.Error)
If (e.Error IsNot Nothing) Then
model.Error_Text = e.Error.HResult
model.Error_Text = e.Error.Message.ToString
model.TimeStamp_Error = DateTime.Now()
ef_model_smtp_resend.Write_Smtp_Send_Record(model)
End If
End Sub
Thanks for the help Richard!
It would of taken me days to figure out the handler.
|
|
|
|
|
Hi.
How do you check to see the full length of a string coming from a RS232 port and how to 'TRIM" unwanted characters?
Thanks in advance.
|
|
|
|
|
The same way you do with any string from any provider. When reading from an external source (RS232, TCP/IP etc.) you need the source to also provide information as to the length of the string. Either by delimiters, meta information or similar means.
|
|
|
|
|
Depends on how you read it.
In VB you should generally do something like:
com1 = My.Computer.Ports.OpenSerialPort("COM1")
com1.ReadTimeout = 10000
Do
Dim Incoming As String = com1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Incoming is just a string - you can trim, replace chars etc to suit.
ReadLine reads from the serial port, until the first newline char.
Do another ReadLine to get the next bit.
Alternatives:
ReadChar - reads one character
ReadByte - ditto for one byte
ReadTo - Read up to a given char
ReadExisting - Read whatever is in port buffer
This is a good tutorial on how to do serial port comms in VB: http://www.me.umn.edu/courses/me2011/smartprodcourse/technotes/docs/serial-port-vb.pdf[^]
|
|
|
|
|