|
Thats great, thanks very much ;o)
Jim
|
|
|
|
|
Hi
ive created a program that will read a file, check it for the word "error" and then email me with a list of all new errors in the file. im now trying to get the program to read the file every 5 minutes and then send email notification only if there are new errors - could some1 pls help? here's my code so far, which was working until i started to get the timer working!
Imports System
Imports System.IO
Imports System.Collections
Imports System.Web
Public Class Form1
Inherits System.Windows.Forms.Form
Private Shared myTimer As New System.Windows.Forms.Timer
'Private Shared exitFlag As Boolean = False
Private Shared Sub TimerEventProcessor(ByVal myObject As Object, ByVal myEventArgs As EventArgs)
myTimer.Stop()
Dim LineNo As String
Dim CurrentLineNo As New Integer
If GetSetting("OrEM", "Settings", "LineNo") = "" Then
SaveSetting("OrEM", "Settings", "LineNo", "1")
End If
LineNo = Val(GetSetting("OrEM", "Settings", "LineNo"))
Dim objReader As New StreamReader("c:\ProjectSearch\sx3liveALRT.LOG")
Dim sLine As String = ""
Dim arrText As New ArrayList
Do
sLine = objReader.ReadLine() : CurrentLineNo = CurrentLineNo + 1
If CurrentLineNo >= LineNo Then
If InStr(UCase(sLine), "MON") Or InStr(UCase(sLine), "TUE") Or InStr(UCase(sLine), "WED") Or InStr(UCase(sLine), "THU") Or InStr(UCase(sLine), "FRI") Or InStr(UCase(sLine), "SAT") Or InStr(UCase(sLine), "SAT") Then
sLine = objReader.ReadLine() : CurrentLineNo = CurrentLineNo + 1
If InStr(UCase(sLine), "ERROR") Then arrText.Add(sLine)
While sLine <> ""
sLine = objReader.ReadLine() : CurrentLineNo = CurrentLineNo + 1
End While
End If
End If
If Not sLine Is Nothing Then
End If
Loop Until sLine Is Nothing
objReader.Close()
'create mail notification
Dim mailMsg As New System.Web.Mail.MailMessage
mailMsg.BodyFormat = Mail.MailFormat.Text
mailMsg.To = "???"
mailMsg.Subject = "???"
mailMsg.From = "???"
Dim txtBody As String
For Each sLine In arrText
txtBody = txtBody & sLine & vbCrLf
Next
mailMsg.Body = txtBody
System.Web.Mail.SmtpMail.SmtpServer = "???"
System.Web.Mail.SmtpMail.Send(mailMsg)
SaveSetting("OrEm", "Settings", "LineNo", Trim(Str(CurrentLineNo - 2)))
LineNo = Val(GetSetting("OrEM", "Settings", "LineNo"))
' myTimer.Start()
'adds the event and the event handler for the method that will process the timer event to the timer
AddHandler myTimer.Tick, AddressOf TimerEventProcessor
CurrentLineNo = 0
'sets the timer interval to 5 minutes
myTimer.Interval = 30000
myTimer.Start()
'runs the timer, and raises the event
' While exitFlag = False
'Processes all the events in the queue
Application.DoEvents()
'End While
End Sub
Chrissy Callen
|
|
|
|
|
Since I am not sure what OS you are running on I can’t make a concrete recommendation but why not use the available system scheduler that exists in the OS and not worry about that part in your application.
Most OS today offer some type of scheduler to automate tasks running at specific intervals.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Hi there Ok, the timers seems fine now, next prob is this: I want the program to email only if the file contains new "errors" but NOT to email if there are no new instances of the "error" word. so i wrapped the mail code in if sline <> "" then ... (mail code)...end if and it doesnt seem to mail at all now (i added errors manually to the file to check it). Could u pls tell me where im going wrong? Thanx!
Imports System
Imports System.IO
Imports System.Collections
Imports System.Web
Module Module1
Sub Main()
Dim myTimer As New System.Timers.Timer
Dim LineNo As String
myTimer.Stop()
Dim CurrentLineNo As New Integer
If GetSetting("OrEM", "Settings", "LineNo") = "" Then
SaveSetting("OrEM", "Settings", "LineNo", "1")
End If
LineNo = Val(GetSetting("OrEM", "Settings", "LineNo"))
Dim objReader As New StreamReader("filename")
Dim sLine As String = ""
Dim arrText As New ArrayList
Do
sLine = objReader.ReadLine() : CurrentLineNo = CurrentLineNo + 1
If CurrentLineNo >= LineNo Then
If InStr(UCase(sLine), "MON") Or InStr(UCase(sLine), "TUE") Or InStr(UCase(sLine), "WED") Or InStr(UCase(sLine), "THU") Or InStr(UCase(sLine), "FRI") Or InStr(UCase(sLine), "SAT") Or InStr(UCase(sLine), "SAT") Then
sLine = objReader.ReadLine() : CurrentLineNo = CurrentLineNo + 1
If InStr(UCase(sLine), "ERROR") Then arrText.Add(sLine)
While sLine <> ""
sLine = objReader.ReadLine() : CurrentLineNo = CurrentLineNo + 1
End While
End If
End If
If Not sLine Is Nothing Then
End If
Loop Until sLine Is Nothing
objReader.Close()
If sLine <> "" Then
'create mail notification
Dim mailMsg As New System.Web.Mail.MailMessage
mailMsg.BodyFormat = Mail.MailFormat.Text
mailMsg.To = "me@co.uk"
mailMsg.Subject = "name"
mailMsg.From = "name"
Dim txtBody As String
For Each sLine In arrText
txtBody = txtBody & sLine & vbCrLf
Next
mailMsg.Body = txtBody
System.Web.Mail.SmtpMail.SmtpServer = "server"
System.Web.Mail.SmtpMail.Send(mailMsg)
End If
SaveSetting("OrEm", "Settings", "LineNo", Trim(Str(CurrentLineNo - 2)))
LineNo = Val(GetSetting("OrEM", "Settings", "LineNo"))
CurrentLineNo = 0
myTimer.Interval = 30000
myTimer.Start()
End Sub
End Module
Chrissy Callen
|
|
|
|
|
Hello all!
I have a problem with my application.
After completion of my program, when I install it to some other PC & try to run it, it gives me "path not found error" for database file. I have used Ms Access file as my backend.
I use Data Adapter Configuration Wizard to make Oledbadapter, Oledbconnection & Dataset. I then realize that the path of my backend file is set according to my computer's path. Someone told me to use Application.Startuppath in connection string.
Now I want to know here how to use it, & specially where to use it?
As I have mentioned earlier that I use wizard to make connection object, I copy the connection string from oledbconnection's property window & copy it to my form's load event like so (but I didn't delete the Oledbconnection object):
Dim cnn as new oledbconnection
dim path as string = application.startuppath & "\" & "Database.MDB"
cnn.connectionstring="........, Data source=" & path & ",..........
But this thing didn't work here. I still got path error, or sometimes I got this error "Object reference not set to an instance of an object."
Isn't there a way by which I can solve this problem? I am using wizard as I am not so familier with VB.NET.
Can anyone help me to complete my project.
Thanx in advance.
|
|
|
|
|
A couple of questions...
Is the Database.MDB file shared on a server somewhere or is it local to the client machine?
If it is supposed to be local, is the file part of the installation?
If it is part of the install, where is the file being written to?
RageInTheMachine9532
|
|
|
|
|
The file is not shared, its local to client system.
I want to deliver this database file to my client, so I added it while I develop my setup & package. So when the setup is run, the file is also installed to application's folder.
Now for your last question, sorry I don't understand what you want to say. Its a simple Ms Access file having some tables & relationships between them. That's it. I just want to deliver this file alongwith my application so I add it with the application.
Waiting for reply.
Thanx...
|
|
|
|
|
Are you absolutely sure the database file is being written to the same directory as your .EXE?
RageInTheMachine9532
|
|
|
|
|
I am using the componentone TrueDBGrid and i want to use Celltips. Using the FetchCellTips event is can populate the celltip with informnation. However i cant set the tooltip to multiline or grow so when i have a long celltip it is displayed as one long line.
Anyone?
Grtz, Guus
|
|
|
|
|
I had the same problem and I could solve it but when I try it on a different application it worked and which IDE are you using in VB.NET
Regards
Stepdaddy
|
|
|
|
|
I am using VB6. Even tried strTip = "Hello" & vbcrlf & "World"
didnt work
Grtz, Guus
|
|
|
|
|
|
hello friends,
iam developing an application. i want to insert a picture from my front end . this picture has to be saved in the sql server database. how can i do it
|
|
|
|
|
vb6 and ADO or Vb.Net and ADO.NET ?
if vb6:
check the AppendChunk method of the field object
you can load the picture in an array then add it to that field.
|
|
|
|
|
how do i go about scanning an image with an adodb control with access as a backend and VB6 as the front end.THis is needed for the purpose of the project regarding automating the registrations of a computer institute.
PRAVEED
|
|
|
|
|
Are you f***ing mad. Try and do something else like have sex. F***er?????
|
|
|
|
|
Use ADODB to scan an image? Bottom line is -> you can't. That's not what ADODB does.
Are you trying to capture an image from a video camera? If so, what kind? A QuickCam?
For something like that, your going to need a SDK from the manufacturer of the camera to get at an image. Logitech has one that works with its line of QuickCams at http://developer.logitech.com.
RageInTheMachine9532
|
|
|
|
|
I start my project with a module called SubmainController.vb which contains a Public Sub Main()
In this public sub main I want to call a sub from another form in the project. I’ve tried the following without ant success.
Dim Myform1 as new Form1
Call Myform1.LoadFromFile
(property access my assign to the property or use its value
Dim ProjectName as string “Web Project”
Call ProjectName.Myform1.LoadFromFile
(myform1 not a member of string)
I though this would be simple. I appreciate help
Thanks GregC
Thanks, GregC
|
|
|
|
|
How about making the Sub a Public method of a separate class, thus making it available to both forms without the need of instantiating either form unneccessarily. As an alternative, if the method is declared Shared , it should be accessible even without creating an instance of the form, simply by calling Form.MethodName() .
Oh, and you don't need to use "Call" anymore.
|
|
|
|
|
Hi should have added that this is an event.
Public Sub loadFromFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loadFromFile.Click
is it possible to raise an event on another form from a sub main? i'm not quite sure how to code that. Would i need to change the above click event code and how would I call or raise the event from the sub main? And would rasing the event execute the click event?
Thanks, GregC
|
|
|
|
|
You can certainly do something like what you describe; here's what I did:
Module MainModule
Sub Main()
FormRaisingEvent.LoadFromFile(New Object, New EventArgs)
End Sub
End Module
and the form's code looks like this:
Public Class FormRaisingEvent
Inherits System.Windows.Forms.Form
' Windows Form Details omitted...
Public Shared Sub LoadFromFile(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("Hello!")
End Sub
End Class
The important things are 1) declare the Sub as Shared and 2) when you call the method of the form from somewhere else, pass it the parameters required in the method's signature.
Let me know if this answers your question.
|
|
|
|
|
Hi John, THANKS! It worked GREAT!
Thanks, GregC
|
|
|
|
|
Hi....
Can anyone tell me how can I retrieve info about what software that have been installed on a pc and how can I read REG_Binary?
|
|
|
|
|
Not sure about the REG_Binary part. Do you want to read registry values in VB6 or .NET?
|
|
|
|
|