|
Yep. C# doesn't support option parameters, no matter what the type of the parameters are.
The absolute #1 skill you can have as a developer/programmer/whateverYouWantToCallIt is the ability to do research, not write code. You searched for a VERY specific occurance of a situation and stopped there. You didn't generalize your search parameters at all when you Googled for "optional date parameter with default value". You should have opened this up to possibly more hits by searching for "C# optional parameters".
|
|
|
|
|
Thank you for the tip
Shay Noy
|
|
|
|
|
No, despite my pleading, the C# team refuses to impliment them. They are stuck on the idea that it has to be complicated ( i.e. support for named parameters, etc )
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
No.
you can not specify an expression/variable while defining an optional parameter.
it needs to be a constant......
Ashish Sehajpal
|
|
|
|
|
Try this :-
Function f(Optional Byval d as Date = nothing) as object<br />
If d = nothing then<br />
d=System.Date.Today<br />
End If<br />
' rest of your code here<br />
End Function
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Thank you , this is what I am doing but this function is a part of a dll that I wrote and it is used by 5 different programmers.
When they used this function then instead of seeing that the optional date is set to today they see that the optional date is set to nothing (#12:00:00#). It is not very elegant for the programmer.
Shay Noy
|
|
|
|
|
Agreed, but I see no other solution. I would suggest that you add a metadata description to the function and detail what will happen if the date passed to the function is nothing.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
|
In works in VB.NET 2005 and 2008. On the line emmediately above the function, sub, property etc type 3 single quotes ie ''' The rest is done for you.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
You right it works if the function, sub , property are as part of the same project. But try to write a dll, add ''' in one of your function and use this dll in one of your applications, it will not work.
Shay Noy
|
|
|
|
|
Then forget the optional parameter and write an overloaded function, one that takes a Date parameter and one that doesn't. In the one that doesn't, you simply declare an internal variable that's set to todays date.
|
|
|
|
|
|
Hi all,
I'm developing an application in VB2005.Net 2.0 and I would like to use a C header file that contains many structs that I need in the project. This structs are going to change quite often so I wouldn't like to migrate the structs from the C file to VB code each time that the header file changes. The best thing for me would be to include the '.h' file directly into my project so I could access it directly.
Is it possible to do it in any way? Could it be possible to do it encapsulating the '.h' file into a library and then reference it from the VB project?
Thanks in advance for any idea you have,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Perhaps if you make a C++/CLI dll, you could do it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I've done it but I just have access to the struct name and not to its subelements. I mean:
In the .h header file:
<br />
....<br />
public struct S_ERRORS{<br />
unsigned char uHall2;<br />
unsigned char uHall1;<br />
}<br />
...<br />
Inside the VB project, I can declare a S_ERRORS variable but I cannot access to its element: uHall1, uHall2
Is there any way to access to this elements?
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Marc Soleda wrote: I've done it
Done what?? Did you compile this into a MANAGED (C++ CLI) .DLL or into a normal Windows library .DLL (unmanaged code). If unmanaged, you won't be able to use the structures defined in the .DLL.
|
|
|
|
|
Into a C++/CLI dll: I can declare a structure variable defined in the library but no access to its elements
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
I have a datagrid view which has cell editing enabled.
I have added a button column in the first column.
Now i want that if user edits a row and then wants to cancel the edit on that row he can do that by clicking on that button.
I have tried Canceledit of datagridview but the datatable bind to that datagrid has the changes even after this.
How can i cancel the updates in the grid on click of the button present for every row
|
|
|
|
|
Without seeing the code you're using to cancel the operation, what the data source is, it's kind of difficult to tell. CancelEdit only works if the data source supports the IEditableObject interface and EndEdit must NOT be called between the time the edit is started and the call to CancelEdit.
|
|
|
|
|
Dim dt As New DataTable
Dim ad As New SqlClient.SqlDataAdapter("Select Top 5 * from T010011", "server=.; database=WSS_4;uid=sa;pwd=; current language=us_english")
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cb As New SqlClient.SqlCommandBuilder(ad)
ad.Fill(dt)
DataGridView1.DataSource = dt
DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter
End Sub
Private Sub GlassButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GlassButton1.Click
ad.Update(dt)
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
DataGridView1.Rows(e.RowIndex).Cells(1).Value = My.Resources.top_left_back
End Sub
Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If DataGridView1.Rows.Count > 0 Then
'DataGridView1.Rows(e.RowIndex).Cells(1).Value = My.Resources.top_left_back 'CType(iconColumn, DataGridViewImageColumn)
End If
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If e.ColumnIndex = 0 Then
DataGridView1.CancelEdit()
Else
End If
End Sub
//////////////////////////
A user can edit 10 rows and in the end wants to update only 5 of them so rest he can cancel by clicking cancel button in the Grid.
|
|
|
|
|
Hi All,
I am developing one application with VB 6.0 and MS Access.
I am using the following connection string to connect to database.
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\9.124.124.90\sanramal1\overtime log\Overtime Log\Data\OT_Log.mdb"
In the above I have given the IP address of the system where the database OT_Log.mdb is located.
But I am facing problem that is, Since the IPAddress is dynamic I cannot give the IP address , so I thought of using the MAC Address of the System ( Which is static even the IP address is changed). (Mac Address - Physical Address).
But I dont have any idea how to give the MAC address in the connection string instead of IPAddess.
Or is there any code to recover ip address by giving the mac address.
Please Please help me.
Thanks you all in advance,
Regards
|
|
|
|
|
I would suggest looking into something like DynDNS and using that
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Thanks lot.
Can you give me little more about DynDNS.
Regards,
|
|
|
|
|
Please read the article I link to in my sig.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Can you not use the computer name rather than its IP Address?
e.g.
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\MyDataServer\sanramal1\overtime log\Overtime Log\Data\OT_Log.mdb"
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|