|
Johan is correct of course. I was giving you the quick answer!
The time, depending on whether it is always fixed or may change can either be in the tick event (if the value is never going to change), or as a user setting (if the user can change it), or as some other module level variable which is set on form load etc etc.
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim tmeFireAt as Date = "01:30"
If TimeValue(Now) = tmeFireAt Then
'Or whatever checking you feel you need to see if the time has been reached Hour() Minute() Second() etc etc
Timer1.Enabled = False
'
'do stuff
'
Timer1.Enabled = True
End If
End Sub
Private tmeFireAt as Date = "01:30"
'
'
'
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If TimeValue(Now) = m_tmeFireAt Then
'Or whatever checking you feel you need to see if the time has been reached Hour() Minute() Second() etc etc
Timer1.Enabled = False
'
'do stuff
'
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If TimeValue(Now) = My.Settings.FiringTime Then
'Or whatever checking you feel you need to see if the time has been reached Hour() Minute() Second() etc etc
Timer1.Enabled = False
'
'do stuff
'
Timer1.Enabled = True
End If
End Sub
|
|
|
|
|
Hello Johan Hakkesteegt
I tryed to pm you but i can figuer how i can do that but anyways
i just wated to thanks you and everyone else that help me out
and having lost of patients i am not the best at vb but i am lerning
more and more every day
with your help i got what i wanted to do working perfect Thanks
I will have to get you a beer
Thanks
Bob
|
|
|
|
|
Firstly, are you sure your app will be running at that precise time? If not, why not just create a console app and schedule it with the windows scheduler - much more reliable I would have thought.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
MY app will be running 24 7
|
|
|
|
|
In which case, just set the timer to the difference between the current time and the required time (remembering to use the date as well - I forgot once )
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi all, how can i insert excel worksheet in vb.net form that can be applied excel formula in the worksheet.
Thanks in advance..
Regards
|
|
|
|
|
Hello Thare
I am new at this but i am also working with excel and found this site that was very usfull hope it is usfull for you too
http://vb.net-informations.com/excel-2007/vb.net_excel_2007_create_file.htm
look at the bottom of the page thare is all kinds of Related Contents
|
|
|
|
|
I am assuming what you are saying is that you want to disply an Excel worksheet in a form. You could link to Excel using Excel as a COM server (objExcel as Excel.Application) or you could get an excellent control like Spreadsheet Gear which makes what I am assuming you want to do very easy.
If you search the message boards here with 'using excel in vb' you will get 31 pages of results. You might find something useful there!
Alternatively you might find this useful: ExcelSpreadsheet.aspx
|
|
|
|
|
you could use OWC (office web control) to show the excel files and work with it on a form.
|
|
|
|
|
Hi,
I want to add new control at run time . I had written the code to add a new control to the Main Panel in the Data recieved event of the Serial port like this : -
Public Sub portname_DataRecieved()
Dim pnl as new Panel()
Dim pts As New System.Drawing.Point(pt.X, pt.Y)
pnl.Location = pts
pnl.BackColor = System.Drawing.Color.YellowGreen
MainPanel.Controls.Add(pnl)
End Sub
But I am getting the error at the line MainPanel.Controls.Add(pnl) that is cross-thread operation is not valid how can I remove it.
Thanks
|
|
|
|
|
Use current forms Invoke method to call MainPanel.Controls.Add method, hopefully it will resolve the issue.
|
|
|
|
|
I had tried the following code : -
If MainPanel.InvokeRequired Then
MainPanel.Invoke(AddControlToConatiner)
End if
Public Function AddControlToConatiner()
pnl.Location = pts
pnl.BackColor = System.Drawing.Color.YellowGreen
MainPanel.Controls.Add(pnl)
Return 0
End Function
but the problem still remains the same what is the error can u tell or an example
|
|
|
|
|
You're creating a control on a background thread. Don't. Have the AddControlToContainer method create the control. All controls should be created on the UI thread, not on a background thread.
|
|
|
|
|
Hi all
I'm trying to get a value of a column in DataGrid and insert it in Oracle Table. Below is my code.
Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim oradb As String = "Data Source=(DESCRIPTION=" _
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Mahasilbkp.ltuisb.net)(PORT=1521)))" _
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=db21a)));" _
+ "User Id=" + Label5.Text + ";Password=<pass>;pooling=false;enlist=false;"
Dim conn1 As New OracleConnection(oradb)
conn1.Open()
Dim cmd1 As New OracleCommand
cmd1.Connection = conn1
GridView1.DataBind()
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" + ",'" + Label5.Text + "'" + " " + "from uu.total_cases where trim(ntn)='" + val.Text.ToString + "'"
Dim dr1 As OracleDataReader = cmd1.ExecuteReader()
dr1.Read()
dr1.Dispose()
dr1.Close()
cmd1.Dispose()
conn1.Dispose()
conn1.Close()
End Sub
When I click on Delete it gives the following error:
Object reference not set to an instance of an object.
Source Error:
Line 49: cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" + ",'" + Label5.Text + "'" + " " + "from uu.total_cases where trim(ntn)='" + val.Text + "'"
If I remove the "val.Text" from the above code then it works, but obviously the results are not as I desire. Please help me with this.
Thanks.
|
|
|
|
|
val.Text.ToString ?? What is the object val ??
If it is a text box, try naming it to something else.
|
|
|
|
|
val is a declared label to store the data from the NTN column of the grid
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
Thanks.
|
|
|
|
|
I suspected that. Probably not a good idea to have a label with the same name as a VB function. I am not saying that this is the cause of your problem, but try renaming that label first. Dim lblNTN As Label would be much more readable.
Actually looking at this, where is this label being created?
Dim val As Label = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
What is control "NTN"?
|
|
|
|
|
As TheComputerGuy said and then try:
Dim lblNTN As New Label
lblNTN = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok guys i tried that, but I am still getting that "Object reference not set to an instance of an object" on the insert statement.
Just want to clarify that "NTN" in
lblNTN = DirectCast((GridView1.Rows(e.RowIndex).FindControl("NTN")), Label)
is the name of the column of the Data Grid from which I want the data to be retrieved. Am I doing it the correct way? If not please help with this.
Thanks.
|
|
|
|
|
You might as well just forget about the label completely, and try something like this:
cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector" _
& ",'" & Label5.Text & "'" & " from uu.total_cases where trim(ntn)='" _
& GridView1.Rows(e.RowIndex).Cells("NTN").Value & "'"
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok guys "GridView1.Rows(e.RowIndex).Cells("NTN").Value" gives error on the "value" as it does not recognize it. So I used "GridView1.Rows(e.RowIndex).Cells("NTN").Text". Now I am getting the following error
System.FormatException: Input string was not in a correct format.
it is coming on this line.
Line 54: cmd1.CommandText = "insert into uu.record_backup(ntn, name, status, enf, aud, sector, delete_user) select ntn, name, status, enf, aud, sector,'" + Label5.Text + "' " + "from uu.total_cases where trim(ntn)='" + GridView1.Rows(e.RowIndex).Cells("NTN").Text + "'"
Please help me where I am making mistake in the above line.
Thanks for your help.
|
|
|
|
|
Hi all, i want to retrieve value from dataset. I build dataset from sql data adapter,
Dim strSQL As String
strSQL = "select name FROM sysobjects WHERE xtype='U' and name = 'OPEX" & Str(jumtbl) & "'"
Dim dachecktable As SqlDataAdapter = New SqlDataAdapter(strSQL, oConnection)
Dim dschecktable As New DataSet
dachecktable.Fill(dschecktable, "DSchecktable")
If dschecktable.Tables(0).Rows.Count > 0 Then
----> how can i retrive the item data from dataset dschecktable
' strSQL = "drop table "
End If
Thanks in advance
|
|
|
|
|
What have you tried ? What does MSDN say ?
You already have the code to check if there's rows in the table ( although it does assume one table exists ). You can foreach over the rows, or address them by index. Then for each row, you can index fields or address them by name
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I found it at last, i have to create datarow first, this what i got, advice me if there is better way.
Thank you
|
|
|
|
|
you don't *create* a datarow, you iterate over the ones that are already in your table.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|