|
The datetime class has a 'DayOfWeek' property, which makes what you want to do a snap. Set your date to the first of the month, check the day, and then step forward to the right date from there. Last Monday is same, just work backwards.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i'll try,
thank you!
Fuel2Run
|
|
|
|
|
Hey
I was wondering if anybody knows or can point me in a direction of where i need to go. I'm trying to write a vb .net app to replace our current server Manager program. This lists all available servers on our Domain. The problem that i'm running into is Showing currently used Shared files, username and if it's locked or not. I used WMI to list all available shares on the server. If anybody could point me in the direction needed, or has an example, it'd be very greatly appreciated.
Thanks
Gerry
|
|
|
|
|
I'm having problem on the following code:
Public Class ExpenseEntity
Public Function saveNewExpense(ByVal tempName As String, _
ByVal tempType As String, _
ByVal tempAmt As Integer, ByVal tempCatID As Integer)
Dim cnNewEx As SqlCeConnection = New SqlCeConnection( _
"Data Source=\My Documents\PFMS.sdf; password=9EbK63Lj")
Dim SQLNewEx As String
Dim cmdSQLEx As SqlCeCommand
Dim getEName As SqlCeDataReader
Dim tempID As Integer
SQLNewEx = "INSERT INTO ExpenseDetail(expenseID, catID, eType, eAmount) " & _
"VALUES (" + tempID + ", " + tempCatID + ", '" + tempType + "', " + tempAmt + ")"
cmdSQLEx = New SqlCeCommand(SQLNewEx, cnNewEx)
cmdSQLEx.CommandType = CommandType.Text
cmdSQLEx.ExecuteNonQuery()
cmdSQLEx.Dispose()
cnNewEx.Close()
I receive the error as: "An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: InvalidCastException"
Please help... thanks in advance
|
|
|
|
|
Lot of code here. which line has the exception, or didn't you bother to step through in the debugger ?
I'd imagine that when you set SQLNewEx, that one of the objects you're passing in does not convert to string by itself.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for your reply....
Some how I get to manage solve the error through out the night. The exception is occur at the last SQL statement.
|
|
|
|
|
yes, that's where I said. That means sometimes the variables you're passing through are either null, or some type that can't be converted to string. You need to write some code to protect against bad values, and insert an appropriate value into your SQL.
Doing it as a stored procedure would be even better. It seems mostly in VB land that people ignore this basic design step.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Add .ToString() to your integer types. For example, instead of tempID use tempID.ToString() .
|
|
|
|
|
Thanks for your reply....
Some how I get to manage solve the error through out the night. The problem solve when replace '+' with '&' in SQL statement.
|
|
|
|
|
That works by itself, actually
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You should say in the end to datagrid to bind itself.
DataGrid1.DataBind()
|
|
|
|
|
howdy,
I'm having trouble adding a new row to my primary table.
I have a bunch of comboboxes bound to lookup tables and a tertiary binding for each binding selectedValue to the main datarow.
When I try to change the values, and save, the last comboBox fails to change the lookup ID in the primary table, and remains -1, the initialization value.
any ideas?
[snip]
Me.UcInspect1.ucicmbCLLI.DataSource = Me.dvClli<br />
Me.UcInspect1.ucicmbCLLI.DisplayMember = "CLLIName"<br />
Me.UcInspect1.ucicmbCLLI.ValueMember = "CLLIId"<br />
Me.UcInspect1.ucicmbCLLI.DataBindings.Add(New Binding("SelectedValue", Me.dvInsp, "ClliID"))
[snip]
Private Sub newInsp(ByVal sender As Object, ByVal e As System.EventArgs)<br />
Me.dvPlant.RowFilter = "InspNumber = '-1'"<br />
Dim dr As clDatalayer.dsInspData.InvRow<br />
dr = Me.dsData.Investigation.NewRow<br />
With dr<br />
.InspNumber = 0<br />
.CoID = 3<br />
.InvTypeID = 1<br />
.ReasonsID = 1<br />
.InvID = 123<br />
.ExchID = -1<br />
.ClliID = -1<br />
.StatusID = 1<br />
End With<br />
Me.dsData.Investigation.Rows.Add(dr)<br />
Me.BindingContext(Me.dvInsp).EndCurrentEdit()<br />
Me.BindingContext(dvInsp).Position = Me.BindingContext(dvInsp).Count - 1<br />
<br />
End Sub<br />
[snip]
Set the Values in the UI...
At this point all values have changed excapt CLLIID which is still '-1', even though I've selected a CLLI, and the combobox.selectedvalue <> -1. very strange.
[snip]
Private Sub SaveInsp(ByVal sender As Object, ByVal e As System.EventArgs)<br />
Me.BindingContext(Me.dvInsp).EndCurrentEdit()<br />
Dim i As Integer = Me.BindingContext(Me.dvInsp).Position<br />
Me.BindingContext(Me.dvInsp).Position = 0<br />
Me.BindingContext(Me.dvInsp).Position = (i)<br />
Try<br />
Me.procData.setData = Me.dsData 'runs datalayer update<br />
Me.BindingContext(Me.dvInsp).Position = i<br />
MsgBox("Changes Saved")<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
End Sub<br />
let me know if you have any ideas...It just seems like that last combo isn't committing it's changes.
TIA
Jeremy
Thank you, Thank you, I'll be here all week...
|
|
|
|
|
Hi,
I have a litle problem and I wonder if someone could help me to start while creating MS Word output from VB.
I have to create output (.doc file) which will contain text, pictures, tables, etc.
Examples, references on web pages, .pdf files, web tutorials, e-books, will do.
Deeply Thnx!
Zlatko Stapić
|
|
|
|
|
Microsoft Word uses it's own document architecture. VB provides no support for creating output in the correct Word format.
You need to add a reference to the Word object library to your VB project, then use the Word COM interface to manipulate documents programmatically. The MSDN contains tons of reference materials on using the Word object library functions.
Robert
|
|
|
|
|
Thanks for your reply...
I found lots of materials in MSDN, and solve almost all my problems. One thing is waiting, and that is how to save a created document, but without any
"save as" dialog boxes. But, I thing I'll manage that too.
Thanks Again...
|
|
|
|
|
Thanks for your reply...
I have done some digging in MSDN, and as you said, I found almost everithing I need. Actualy I solved all my problems, except one, and that is how to save a created word document without any "save as" dialogs. But I think I'll manage that too...
Thanks again....
|
|
|
|
|
|
I want undo a text in richtextbox suchas in notepad.exe
How create new form effect richtextbox of previous form (such as form find&replace in notepad.exe)
|
|
|
|
|
Hi,
I am upgrading an application from Vb6 to Vb.net. I am facing a problem in converting Propertybag object. Like it is storing some value with .WriteProperty and then for retrieving .ReadProperty.
Can any one tell me Vb.Net equivalent for that?
thanks
Het Waghela
Be Humble in Victory and Strong in Defeat.
Het Waghela, Blog|Het Waghela DotNet Questions Link|More Links
|
|
|
|
|
NET does not support the PropertyBag object. You have to use NET Serialization instead. Do a MSDN search on Serialization to see simple implementations.
Robert
|
|
|
|
|
|
hello friends,
i want to know about the thread start in the VB.
how can i start the thread using ThreadStart in visual basic.
i use the CreateThread, CloseHandle, TerminateThread etc. but all these are not fulfilling my requirement.
i want when my task is over, the thread is terminated.
how it is possible?
please help me? here is a question of my job...
thanks
Gagan Deep Singla
Chandigarh - INDIA
|
|
|
|
|
Dim t As System.Threading.Thread
t = new Threading.Thread(AddressOf MySub)
t.Start()
The thread will terminate when the code reaches the end. A good way to do tasks in a thread is to encapsulate the thread and task in a class:
Public Class MyTaskClass
Private MyThread As Thread
Public Sub New
Me.MyThread = New Thread(AddressOf Me.MyTask)
End Sub
Public Sub Start
Me.MyThread.Start()
End Sub
Private Sub MyTask
'Start processing here
End Sub
End Class
You can add properties to the class which can be read after the thread has stopped. You can also raise events when something important happens in the thread, maybe telling you that there is important information available through the properties.
When the thread reaches the end of code, it stops. You can't restart it, so if you want to perform the task again, you have to create a new instance of the calss.
|
|
|
|
|
thanx for responsing sir,
i am not talking about the VB.net.
i am talking about vb6.0
if you can help me in that then this is benifial for me.
thank you
Gagan Deep Singla
Chandigarh - INDIA
|
|
|
|
|
Sorry, I do not remember any details of mutithreading in vb6. I played with it about 6 or 7 years ago and decided not to use vb6 for multithreading. Here is a link explaining some of the reasons not to do multithreading in vb6 (it also will point you towards a solution if you must persue multithreading in vb6):
http://www.freevbcode.com/ShowCode.Asp?ID=1287[^]
|
|
|
|