|
sir;
i think that you need to use Type.GetConstructor() to return an instance of the appropriate type.
Good Luck;
Help people,so poeple can help you.
|
|
|
|
|
Another alternative would be using the Activator , as described here[^].
I are Troll
|
|
|
|
|
Good alternative, Sir.
100
Help people,so poeple can help you.
|
|
|
|
|
I agree great solution, thank you both for the time on this.
|
|
|
|
|
Hi all,
I have a database where the data contains some special chars.
I retrive the data from the dbase (dbf) file with a sql statement and write it into a text file using vb.net.
When I write the text file some of the special characters are not written the same way as in the dbf file, its written as a box.
I'm using:
<br />
Using sw As StreamWriter = New StreamWriter(dbfFile, False, System.Text.Encoding.Default)<br />
while writing to text file.
I'm not sure how to read the exact data from the database.
Is there a special way to do that???
Thanks in advance for anyh suggestion and help.
|
|
|
|
|
if you want to use characters outside the ASCII set, you need either a specific "code page" (not my recommendation) or 16-bit characters (Unicode).
what field type are you using in the database? it should be nvarchar or ntext in most databases for Unicode.
and then better specify Encoding.Unicode explicitly, both when writing to and reading from the database.
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.
|
|
|
|
|
he wrote about dbf (dbase) files ... no nvarchar, only fixed size char fields. in dbf files, the application has to take care of the correct codepage (you can nearly write everything in a dbf char field, except the 0 char).
I cannot remember: What did I before google?
|
|
|
|
|
The linefeed(LF) character is written as a box.
If i have a line feed, i want to ignore it...
ie; ignore only (LF) and not CRLF.
Thanks for any solution.
|
|
|
|
|
You have a solution to this - the ReplaceControlChars sub does this.
It also replaces chars such as tabs (i.e. any control char)
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
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.
|
|
|
|