|
Hello David
Hope you are doing good.
Yes, I know that ReplaceControlChars sub does it, but, its a case where a description contains a LF in between 2 words.
And we found that its an error on the dbf file a line feed should not occur inbetween 2 words in a particular field(column), where as a blank space is allowed inbetween 2 words and once the LF is been removed, the application works fine.
Thanks a lot for the reply.
|
|
|
|
|
hi
how find window lock time and unlock time?
Private Sub Command1_Click()
Shell "rundll32.exe user32.dll,LockWorkStation", vbHide
End Sub
this coding using for locking the windows system.
but i need lock time(ctl+alt+del)
thks
|
|
|
|
|
|
Your code would have to be running on the machine already. Like the other reply stated, you'd have to register for notification of the lock. Windows does not track the lock and unlock times itself, so your code would have to record the times when they happen.
|
|
|
|
|
Hi;
Im using the code wrote by "Dennis Austin" in the link below
A New Task Scheduler Class Library for .NET[^]
Im tring to create new task but I faced an error said : "Object reference not set to an instance of an object".
at line :
t.ApplicationName = "chkdsk.exe";
The whole sub that im using :
//Get a ScheduledTasks object for the local computer.
ScheduledTasks st = new ScheduledTasks();
// Create a task
Task t;
try {
t = st.CreateTask("D checker");
} catch (ArgumentException) {
Console.WriteLine("Task name already exists");
return;
}
t.ApplicationName = "chkdsk.exe";
t.Parameters = "d: /f";
t.Comment = "Checks and fixes errors on D: drive";
t.SetAccountInformation(@"THEDOMAIN\TheUser", "HisPasswd");
t.IdleWaitMinutes = 10;
t.MaxRunTime = new TimeSpan(2, 30, 0);
t.Priority = System.Diagnostics.ProcessPriorityClass.Idle;
t.Triggers.Add(new WeeklyTrigger(6, 30, DaysOfTheWeek.Sunday));
t.Save();
t.Close();
st.Dispose();
Plz help;
|
|
|
|
|
Put your code in Code block
BTW which line throws the error Object reference not set to an instance of an object ? Put Trace in code & run & then tell us.
|
|
|
|
|
The error appear at the bellow line :
t.ApplicationName = "chkdsk.exe";
!!!
|
|
|
|
|
You got that error because t is Nothing, or NULL. You're trying to assign a value to a property on an object that's doesn't exist.
Your could is ASSUMING you got a object back from the CreateTask line above it. You have to check to see if you got a valid object back from that line before you start assigning properties.
|
|
|
|
|
Noticed late.
Your code is in C#. This is VB forum. Please ask your question in appropriate forum(C#) always.
BTW wait for this time, Don't post a duplicate one in any other place.
|
|
|
|
|
Yes, my code is in VB.net
but im using C# coz the origin topic by "Dennis Austin" was in C#.
Here is my code: (I indecate the error line by '>>')
Dim st As New ScheduledTasks(PC.Trim)
Dim tsk As Task
tsk = st.CreateTask("ReportTask")
>> tsk.ApplicationName = "Reports_Manager.exe"
tsk.Parameters = txt_Parameters.Text.Trim
tsk.Comment = txt_TaskName.Text.Trim
If rbtn_anotherPC.Checked Then
tsk.SetAccountInformation(txt_UserName.Text.Trim, txt_Password.Text.Trim)
End If
t.IdleWaitMinutes = 10
t.MaxRunTime = New TimeSpan(2, 30, 0)
t.Priority = System.Diagnostics.ProcessPriorityClass.Idle
Dim i() As Integer = {31}
tsk.Triggers.Add(New MonthlyTrigger(10, 30, i, Now.Month))
tsk.Save()
tsk.Close()
st.Dispose()
|
|
|
|
|
Check whether tsk is null or not. If it is null, debug the code for st.CreateTask("ReportTask") , and thus find out why it is null.
|
|
|
|
|
Hi,
I want to close a form when i hit the esc key.
I don't want to have a visible button.
Now a have a button and after another button (OK button) (When I set the visible to false it's not working) and have set tabkey to false.
Is there a beter way
Jan
|
|
|
|
|
either use a real button (hidden as you did, or located beyond the Form's bounds) or handle the ESC key yourself (Form.KeyPreview=true and KeyDown event handler).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You could use the form keydown, but if there is focus on another object it will not work. You could perhaps set a time to check if the form has focus then use this:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Escape Then
'Me.WindowState = FormWindowState.Minimized
'Me.Hide()
'Me.Visible = False
'Me.Enabled = False
'End
End If
End Sub
Of course remove the ' from the comment for what your trying to accomplish. Several options to choose from.
|
|
|
|
|
you replied to the wrong message, it is jan212r having (or having had) a problem; I offered two solutions, and the KeyDown-based one works fine if you set Form.KeyPreview true, as I explained.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
My apologies. I was merely trying to help.
|
|
|
|
|
No problem.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
At my office we have multiple printers, however only one of them is a color printer. In order to print to this printer you need to enter a valid password into the appropriate box under the printer settings. However there is a file that needs to be printed from my program that always needs to be printed to this printer and printed in color. I know how to select the printer I want to print to, but I don't know how to access these printer specific settings. There doesn't seem to be a way in .NET so I'm assuming I'm going to have to do some DLLImport or something similar. Any guidance would be greatly appreciated it. BTW (in case it helps) this is a Ricoh Aficio MP C4500 network printer. Thanks in advanced.
|
|
|
|
|
DisIsHoody wrote: we have multiple printers, however only one of them is a color printer
DisIsHoody wrote: a file that needs to be printed from my program that always needs to be printed to this printer and printed in color
Looking at this information I am guessing that the printed to this printer requirement is only because it is the only color printer and the file needs to be printed in color. In other words, is it a safe bet to assume that the only real requirement is that the file needs to be printed in color?
If so, the most cost effective solution can probably be found outside of your code. I.e. simply buy another cheap color printer, and dedicate it to this job, or reconsider the need of password protection being on the existing printer, and instead move the printer to a room that can only be entered with a special key or electronic tag, or whatever.
If not, you are going to have to talk to Ricoh about an sdk of sorts, unless it is possible to save the password in the printer settings on the computer that is running the program.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hallo,
I've got an problem with my GUI. My program has to request a couple of websites (POST) and then store the responses in local files.
While requesting the sites, a GUI textbox (tbLog) should inform the user, what site actually is being requested and a "STOP" butten should enable the user to stop the whole process.
Now, when I start work, the GUI freezes and the user cannot do anything until all websites are done. There is no update of tbLog.text at all and no stop button can be pressed.
Me.Refresh() does not help, to.
I read something about threading, but all examples seem to be oversized for my problem.
This is part of my code (simplyfied):
1)Start working by clicking button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.tbLog.Clear()
Dim zaehler As Integer
Do Until (zaehler = 20)
Dim antwortseite As String
antwortseite = getResults("http://localhost/antiquartwo/test-params.php", "field-keywords=ASP.NET 2.0")
' todo: verarbeiten der antwortseite
' anzeige der response in der GUI
Me.tbLog.Text &= antwortseite
zaehler = zaehler + 1
Loop
Me.Refresh()
End Sub
2) Webrequest (POST):
Function getResults(ByVal portalURI As String, ByVal suchbegriff As String) As String
Dim uri As New Uri(portalURI)
'Dim data As String = "field-keywords=ASP.NET 2.0"
Dim data As String = suchbegriff
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Post
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-urlencoded"
Dim writer As New StreamWriter(request.GetRequestStream)
writer.Write(data)
writer.Close()
Dim oResponse As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(oResponse.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
oResponse.Close()
'Response.Write(tmp)
getResults = tmp
End Function
Can anybody help me by optimizing my code?
Thank you. Cipherwar
|
|
|
|
|
Hi,
your code doesn't need optimizing; it is wrong, and it needs a make-over.
As it is, everything runs on the main thread, a big loop gets started by pressing a button, and inside the loop all web pages get loaded using a blocking call (Stream.ReadToEnd). As a result the GUI is dead for as long as that takes. For proper GUI response, you should not have any blocking calls in an event handler!
The easiest solution would be to add one thread that handles the web stuff; in this case a BackgroundWorker would be an excellent choice: whatever you put in the DoWork handler will run on a background thread and not freeze the GUI; so put the fetch loop there. However, you are not allowed to touch GUI accesses from a different thread, and that is where ReportProgress comes in: call that method to pass results onto the ProgressChanged handler which automagically executes on the main thread (assuming it was the main thread that created the BGW to begin with).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks for that hint. I think I know what you mean and I also think my VB experience is not as good as needed to implement that
Maybe you could add one or two code snippets or functions , so that I could use them for my journey into documentation or google-ing ?
cipherwar
|
|
|
|
|
cipherwar wrote: Maybe you could add one or two code snippets
I could.
You should read up about BackgroundWorker on the reference material in MSDN, then maybe a few articles here on CodeProject.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|