|
I can't duplicate the problem. Which version of VB.NET are you using?? Have you put any Menu's or ToolsBars on the child forms??
|
|
|
|
|
I am using vb.net 2005, and i have not put any tool bar or menu bar in child form. its just like a ms word editor where i want to manage documents.
Salman
|
|
|
|
|
OK. I still can't duplicate your problem at all. I can't intentionally break the code to make it do what you're describing. There's some piece of information you've left out that's critical to the problem, but I have no idea what it is. I'd need to see the project to figure it out.
|
|
|
|
|
visual studio 2003:
how can i find out, how much free space is left on a disc?
|
|
|
|
|
You'll have to use WMI to get the freespace in .NET 1.1. The DriveInfo class doesn't show up until .NET 2.0.
I believe you're looking for the Win32_LogicalDisk WMI class. Google results for "Win32_LogicalDisk[^]"
|
|
|
|
|
thanks dave. that's what i am looking for.
|
|
|
|
|
hi.
i m shahid, software engineer working digitalbook inc. i m developing a web browser. i m using webbrowser control. all i need is wen a page contains errors my browser displays an error messagebox while internet explorer just display 'Error on page' in status bar. i don't wana see that error messagebox. how can i do this?? thx in advance.
[ one more thing errors are of javascript]
King
|
|
|
|
|
Have you looked into the ScriptErrorsSupressed property of the WebBrowser control? (Only available in .NET 2.0 and above!)
|
|
|
|
|
Hello there,
I tried a couple of ways and made a lot of changes, however if I run this in debugging mode it works, it stops the timer and display msgbox.
But if I run this outside it does not stop timer and does not display msgbox..
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick<br />
<br />
Timer1.Start()<br />
<br />
Label1.Text = formatDigits(Now.Hour) & ":" & formatDigits(Now.Minute) & ":" & formatDigits(Now.Second)<br />
<br />
Shutdown()<br />
<br />
End Sub<br />
<br />
Private Sub Shutdown()<br />
<br />
Dim myTime As Date = Format(Now(), "hh:mm:ss tt")<br />
Dim StartHour, StartMinute As Integer<br />
Dim EndHour, EndMinute As Integer<br />
Dim StartTime As String<br />
Dim EndTime As String<br />
<br />
StartHour = 6<br />
StartMinute = 0<br />
EndHour = 11<br />
EndMinute = 16<br />
StartTime = TimeValue(StartHour & ":" & StartMinute)<br />
EndTime = TimeValue(EndHour & ":" & EndMinute)<br />
<br />
If myTime >= StartTime And myTime < EndTime Then<br />
<br />
If String.Compare(Now.Hour.ToString, EndHour.ToString) = 0 Then<br />
If String.Compare(Now.Minute.ToString, EndMinute.ToString) = 0 Then<br />
Timer1.Stop()<br />
MsgBox("1st piece")<br />
End If<br />
End If<br />
<br />
End If<br />
<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
Timer1.Enabled = True<br />
Timer1.Start()<br />
<br />
End Sub<br />
<br />
Private Function formatDigits(ByVal Value As Integer) As String<br />
<br />
Dim newValue As String<br />
Dim len As Integer = Value.ToString.Length<br />
<br />
If len = 1 Then<br />
newValue = "0" + Value.ToString<br />
Return newValue<br />
Else<br />
Return Value.ToString<br />
End If<br />
<br />
End Function
I looked at several possibilities and no luck any ideas why this might be?
thanks
|
|
|
|
|
It obvious you don't know how datatype work, or how DateTime works, or how If statements work in the .NET Framework. I would strongly suggest picking up a book on VB.NET for beginners. I lost count of the number of things wrong with this code. But, here are a few of the major problems.
First, In the Timer1_Tick handler, you do NOT nee to call Timer1.Start. It's already started.
The Shutdown method is doing all kinds of thing it does not need to do, if you only understood how Date/Time works in VB.NET, you could reduce this down to a few lines of code.
In the Button1_Click handler, you set Timer1.Enabled to True, then you call Timer1.Start, which does the exact same thing. You only need one of these lines.
FormatDigits isn't even required. The same thing can be accomplished just by specifying the correct formating string where needed.
Your (shortened) code might look something like:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = DateTime.Now().ToString("HH:mm:ss")
Shutdown()
End Sub
Private Sub Shutdown()
' This can be rewritten even shorter, but this is of a level that you should easily understand.
Dim StartTime As New DateTime(Now.Year, Now.Month, Now.Day, 6, 0, 0)
Dim EndTime As New DateTime(Now.Year, Now.Month, Now.Day, 11, 16, 0)
If StartTime <= Now() AndAlso Now() <= EndTime Then
Timer1.Stop()
MsgBox("1st piece")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
|
|
|
|
|
Thanks for pointing out the errors in my code.
As a matter of fact you're right when you suggest me starting from scratch as I only done my first 2 week course in vb.net 3 months ago
So what do you start coding when finished with "hello world" messages. Maybe one day I'll be as good a coder as you helping others on their way..
I made a change to this line in your code because it fires all the time
If StartTime <= Now() AndAlso Now() <= EndTime Then
to this
If Now() <= StartTime Or Now() >= EndTime Then
to have the event fired outside my start and end times
If I want this code to run in the background while other applications are running, will this affect other resources?
thanks Chris
|
|
|
|
|
Xooku wrote: So what do you start coding when finished with "hello world" messages.
You start reading the documentation on the .NET Framework and start writing small apps that let you test and see what various classes do and how to work with them.
Xooku wrote: I made a change to this line in your code because it fires all the time
If StartTime <= Now() AndAlso Now() <= EndTime Then
"Fires all the time"?? What did you set the Interval property on the Timer to?? This code will run every x number of milliseconds because the Timer Tick event is being called every x number of milliseconds.
Xooku wrote: If I want this code to run in the background while other applications are running, will this affect other resources?
Depends on that Timer and what your code is really doing. The faster the Timer Ticks, the more CPU is going to be taken up by whatever code is in the Tick event.
|
|
|
|
|
I've set the timer interval to "1000" for second intervals.
And made the change to this
If Now() <= StartTime Or Now() >= EndTime Then
because ie. startime "10H00" to endtime "18H00", the event must fire any time between "18H00" to the next morning "10H00".
In my previous reply I used a timer. Would this be the correct way then to use threading?
Public Class Form5<br />
Dim t As System.Threading.Thread = Nothing<br />
<br />
Private Sub Shutdown()<br />
<br />
Do<br />
System.Threading.Thread.Sleep(1000)<br />
Dim StartTime As New DateTime(Now.Year, Now.Month, Now.Day, 6, 0, 0)<br />
Dim EndTime As New DateTime(Now.Year, Now.Month, Now.Day, 11, 56, 0)<br />
<br />
If Now() <= StartTime Or Now() >= EndTime Then<br />
MsgBox("1st piece")<br />
t.Abort()<br />
End If<br />
Loop<br />
<br />
End Sub<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
<br />
t = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf Shutdown))<br />
t.Start()<br />
<br />
End Sub<br />
End Class
thankyou Chris
|
|
|
|
|
Xooku wrote: In my previous reply I used a timer. Would this be the correct way then to use threading?
No, it's not. You normally wouldn't start a thread just to run a simple method like that, since it executes in under a few milliseconds. You would normally use threading to start a long-running process that would otherwise hang your user interface so it still responds when the user does something.
In your case, you'd put the entire Timer operation in a seperate thread. You'd create a seperate class that includes the loop, the start and end times, and some code to launch whatever process you need when the time comes.
|
|
|
|
|
Thank you
this has been very helpfull
Chris
|
|
|
|
|
If I want the user to change and save other start & end times and not hard code them the way I did, how would I do this?
|
|
|
|
|
Hi
can someone maybe point me in the right direction
Xooku wrote: If I want the user to change and save other start & end times and not hard code them the way I did, how would I do this?
|
|
|
|
|
hi ,
I want to monitor the power status constantly, and on Power status change launch a program.
I understand that using PowerStatus call in .net 2.0 would do that for me. What I cannot make out is how to keep the form containing PowerStatus call execute it over and over again. Should I do like a do loop for the PowerStatus call or is their a better method that would keep the method execute constantly till the form is loaded.
Using VB VB.NET 2005
modified on Thursday, January 10, 2008 6:46:55 AM
|
|
|
|
|
How about using one of the Timers built into the .NET Framework??
You might want to start with the Timer in the Toolbox and dropping it on a Form.
|
|
|
|
|
Sorry, me again...
I thought of something.
How would one go about loading data from a select statement... like this one:
<br />
Dim connectionString As String = "Initial Catalog=DBName;Data Source=InstanceName;Integrated Security=SSPI;"<br />
Dim cn As SqlConnection = New SqlConnection(connectionString)<br />
Dim sqlCommand As SqlCommand = New SqlCommand("SELECT * FROM StagingEmployer ORDER BY StagingDate", cn)<br />
cn.Open()<br />
Dim TestRowset As SqlDataReader = sqlCommand.ExecuteReader()<br />
Into a dataset. Then you can close the connection to the database... and work with the sorted data in the dataset???
I need help on this matter please.
Thank you in advance
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Okay, you wont beleive it but i figured it out... Now can someone please show me or point me to a link on how to read from a Dataset Once it has the records from the database in it???
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
NEVER MIND...
I got it all figured out
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Support123 wrote: I got it all figured out
Great, but it would be really great if you could post your findings back here too... it will help others looking for something similar and also puts you in the position of giving something back to the community
|
|
|
|
|
Sorry...
Here is what i have and it is working fine now
<br />
Dim DS As System.Data.DataSet<br />
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter<br />
Dim MyConnection As System.Data.OleDb.OleDbConnection<br />
Dim connectionString As String = "Initial Catalog=DBName;Data Source=ServerName;Integrated Security=SSPI;"<br />
Dim cn As SqlConnection = New SqlConnection(connectionString)<br />
Dim strSqlCommand As SqlCommand = Nothing<br />
<br />
' Set Up the Connection String.<br />
MyConnection = New System.Data.OleDb.OleDbConnection( _<br />
"provider=SQLOLEDB; database=DBName; " & _<br />
"Integrated Security=SSPI; server=ServerName;")<br />
<br />
' Set Up the Command to be executed.<br />
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _<br />
"SELECT * FROM StagingGeneric ORDER BY StagingDate", MyConnection)<br />
<br />
' Fill the DataSet with the returned Values from the Database.<br />
DS = New System.Data.DataSet()<br />
MyCommand.Fill(DS, "StagingGeneric")<br />
<br />
' Close The Connection To The DataBase.<br />
MyConnection.Close()<br />
<br />
' Get Data Table<br />
Dim dt As DataTable = DS.Tables("StagingGeneric")<br />
<br />
' For Each Row In The Data Row Check What Action To Follow<br />
For Each row As DataRow In dt.Rows<br />
'MsgBox(Convert.ToString(row(3)))<br />
If Convert.ToString(row(3)) = "U" Then<br />
Dim LastContribDate As String = "''"<br />
If (Len(Convert.ToString(row(1))) > 9) Then<br />
LastContribDate = Left(Convert.ToString(row(1)), 10)<br />
End If<br />
Dim StageDate As String = "''"<br />
If (Len(Convert.ToString(row(4))) > 9) Then<br />
StageDate = Left(Convert.ToString(row(4)), 10)<br />
End If<br />
cn.Open()<br />
strSqlCommand = New SqlCommand("UPDATE stagingGenericTest SET" _<br />
+ " [Member_Number] = '" + Convert.ToString(row(0)) _<br />
+ "', [LastContributionDate] = " + LastContribDate _<br />
+ ", [PaymentStatus] = '" + Convert.ToString(row(2)) _<br />
+ "', [Action] = '" + Convert.ToString(row(3)) _<br />
+ "', [StagingDate] = " + StageDate _<br />
+ " WHERE [Member_Number] = '" + Convert.ToString(row(0)) + "'", cn)<br />
strSqlCommand.ExecuteNonQuery()<br />
cn.Close()<br />
ElseIf Convert.ToString(row(3)) = "I" Then<br />
Dim LastContribDate As String = "''"<br />
If (Len(Convert.ToString(row(1))) > 9) Then<br />
LastContribDate = Left(Convert.ToString(row(1)), 10)<br />
End If<br />
Dim StageDate As String = "''"<br />
If (Len(Convert.ToString(row(4))) > 9) Then<br />
StageDate = Left(Convert.ToString(row(4)), 10)<br />
End If<br />
cn.Open()<br />
strSqlCommand = New SqlCommand("INSERT INTO stagingGenericTest" _<br />
+ " ([Member_Number] " _<br />
+ ", [LastContributionDate] " _<br />
+ ", [PaymentStatus] " _<br />
+ ", [Action] " _<br />
+ ", [StagingDate])" _<br />
+ " VALUES ('" + Convert.ToString(row(0)) _<br />
+ "', " + LastContribDate _<br />
+ ", '" + Convert.ToString(row(2)) _<br />
+ "', '" + Convert.ToString(row(3)) _<br />
+ "', " + StageDate _<br />
+ ")", cn)<br />
strSqlCommand.ExecuteNonQuery()<br />
cn.Close()<br />
ElseIf Convert.ToString(row(3)) = "D" Then<br />
cn.Open()<br />
strSqlCommand = New SqlCommand("DELETE FROM stagingGenericTest" _<br />
+ " WHERE [Member_Number] = '" + Convert.ToString(row(0)) + "'", cn)<br />
strSqlCommand.ExecuteNonQuery()<br />
cn.Close()<br />
End If<br />
Next<br />
Not bad for a days work
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
So now i can just change the connectionString to point to another server (i just used the same server to test on.)
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|