|
No. It's just you're about the 5 millionth person to show up saying "I want code for ____!".
I believe in writing your own code so you can learn. You're also asking for something that is very rarely ever used. You're not likely to find prewritten code for this.
|
|
|
|
|
what's the vb.Net counterpart of the following blocks in Csharp?
public class NullableDateTimePicker : System.Windows.Forms.DateTimePicker
{
public NullableDateTimePicker() : base()
{
base.Format = DateTimePickerFormat.Custom;
NullValue = " ";
Format = DateTimePickerFormat.Custom;
CustomFormat = "dd MMM yyyy";
this.DataBindings.CollectionChanged += new CollectionChangeEventHandler(DataBindings_CollectionChanged);
}
}
class DateTimePickerEditingControl : NullableDateTimePicker, IDataGridViewEditingControl
{
public DateTimePickerEditingControl()
{
this.Format = DateTimePickerFormat.Custom;
this.CustomFormat = "dd MMM yyyy";
}
}
|
|
|
|
|
You know, that there are tools for conversing code from C# to VB.Net, do you? Just google for them.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Never mind. I was making a small mistake.
In block 1 it should be:
MyBase.New
In block 2 it should be:
class DateTimePickerEditingControl<br />
Inherits NullableDateTimePicker<br />
Implements IDataGridViewEditingControl<br />
End Class
I was writing this in the first place:
class DateTimePickerEditingControl<br />
Inherits NullableDateTimePicker, Implements IDataGridViewEditingControl<br />
End Class
|
|
|
|
|
|
Greetings everyone,
I'm going through Stephen Toub's book "Patterns of Parallel programming" to try and figure out the different tips and tricks of parallel programming.
Besides having found few minor errors in the book already, I'm stuck on the example described on page 71:
Public Const NUM_STEPS As Integer = 1000000
Shared Function ParallelLinqPi() As Double
Dim [step] = 1.0 / CDbl(NUM_STEPS)
Return ParallelEnumerable.Range(0, NUM_STEPS).Select(
Function(i)
Dim x = (i + 0.5) * [step]
Return 4.0 / (1.0 + x * x)
End Function).Sum() * [step]
End Function
The VS underlines this whole chunk of code and explains the following:
"Overload resolution failed because no accessible 'Sum' accepts this number of arguments."
Apparently, the Sum() function at the end needs to have a selector (selector As System.Func(of Object,Double)). There is no mention of this in the book =(
What should I write inside the Sum, to make this example work, any ideas?
Thanks...
Agarwaen
|
|
|
|
|
The code you posted works perfectly in VS 2010. Are you using 2005 or 2008?
|
|
|
|
|
I use VS 2010 and get the error described in my message above. That is why I'm stumped, because according to the book it should work, but it doesn't =(
Perhaps I need to import some specific namespace ? If so plz tell me which one...
|
|
|
|
|
Are you using one of the 2010 Betas? I tried it on the VS2010 RC1 release, just created a new standard Console app, typed the code in and it worked.
The only namespace required is System.Linq .
|
|
|
|
|
Darn it, I've figured it out...
Here's how the code should look like:
Public Const NUM_STEPS As Integer = 1000000
Shared Function ParallelLinqPi() As Double
Dim [step] = 1.0 / CDbl(NUM_STEPS)
Return ParallelEnumerable.Range(0, NUM_STEPS).Select(
Function(i)
Dim x As Double
x = (i + 0.5) * [step]
Return 4.0 / (1.0 + x * x)
End Function).Sum() * [step]
End Function
Small errors as this one in the book are beginning to drive me nuts =(
Thank you for your effort Dave Kreskowiak.
*Back to reading the book /*
Agarwaen
|
|
|
|
|
Odd. I used the code EXACTLY (verified 3 times by 2 people) as you originally posted it and it worked fine.
|
|
|
|
|
Dear,
since iam new to vb.net,please help me to pass parameter to for my VB.net project,
here is my code for passing parameter to stored procedure
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim combo As String
Dim SQLEV As SqlClient.SqlConnection = New SqlClient.SqlConnection
SQLEV.ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=db_chart;server=nrppc-mis1\sqlexpress"
combo = ComboBox1.SelectedValue.ToString
Dim command As New SqlCommand("usp_Procedure", SQLEV)
Dim adapter As New SqlDataAdapter(command)
command.CommandType = CommandType.StoredProcedure
With command.Parameters
.Add(New SqlParameter("@Ridfrom", SqlDbType.NVarChar))
.Add(New SqlParameter("@PidTo", SqlDbType.Money)).Direction = ParameterDirection.Output
.Add(New SqlParameter("Returnvalue", SqlDbType.Int)).Direction = ParameterDirection.ReturnValue
End With
End Sub
this is my stored procedure
ALTER PROCEDURE usp_Procedure
@Ridfrom nVarChar(50),
@PidTo nVarchar(20) output
AS
SELECT @PidTo = ProcDetails.Procedure_ID
FROM ReportMaster INNER JOIN
ProcDetails ON ReportMaster.Procedure_ID = ProcDetails.Procedure_ID
WHERE ReportMaster.Report_ID = @Ridfrom
RETURN
|
|
|
|
|
What is the problem apart from the fact that you never execute the command?
You should open an SQLDataReader using
myDataReader = command.ExecuteReader
to get the result of the stored procedure
|
|
|
|
|
Hello ,
I wanna create an VB6 Appln, in which each number between 0-9 has different forecolor .And when the number is pressed specified forecolor for that number should set in cell.Eg: If 0 = Red, 1=Green, 2 =Blue. When 0 is pressed its forecolor should be red and when 1 is pressed its forecolor should be Green and so on. And When 12 is pressed 1=Green and 2=Blue. Can anybody help me to achieve this.Any suggestion Appreciated.What should i start with?
Regards
Rizwan
|
|
|
|
|
mdrizwan_1 wrote: I wanna create an VB6 Appln,
A what? Are you saying that you want to create an Excel AddIn in VB6?
|
|
|
|
|
Hello Dave Kreskowiak,
Thanks for your response. You may assume it as an AddIn. Its a mini project where i can enter number with different colors and save it in Excel or any supportable format. and it should be editable. Any suggestion appreciated?
Regards
Rizwan
|
|
|
|
|
I've never written an Excel AddIn in VB6 and I recommend you don't either. I'd use something far more up-to-date, like VB.NET. You can find examples with a little application of Google. Here...[^]
|
|
|
|
|
Hello Dave,
Thanks for the link .Can you help me for a start ???
Regards
Rizwan
|
|
|
|
|
I already did with the links. I've never written an Excel AddIn, nor have I touched VB6 in about 8 years.
|
|
|
|
|
Thanks for it Dave.
Regards
Rizwan
|
|
|
|
|
Hi All
I Want To Sort The DataGridView by Design And Code
pls Send Me a Code As Sample
Thanks
Thaer
|
|
|
|
|
In what way is the build-in DataGridView sort function not adequate?
|
|
|
|
|
See here.
My signature "sucks" today
|
|
|
|
|
Why can't you find out for yourself?
Look on Google.
Read a book.
I assume that you are in the IT development business or wish to be.
If that IS the case you won't get very far if you ask everyone else to do your work for you.
India I assume?
|
|
|
|
|
I have a total of 65 text boxes which the user can fill in. They are 13 down and 5 across. Each row is related to a particular material (which can change daily -see earlier posts) the columns are for quality of material.
In Debug mode stepping through the code this is what happens:
If I pull up the form and enter data into one textbox and then click on the save button the program goes through the save routine, but there is nothing to save and then it hits the Lost_focus event of the text box and runs through and saves the data to the collection class but doesn't save the information.
If I enter one text box and then tab to another the Lost_focus of the first textbox saves the data to the collection class and then click on the Save button the program saves the info to the tables properly and then runs the Lost_focus event of the second text box.
I don't remember this happening in VB6 so I am sure it has to do with the new form collection class, etc. I am confused and wonder now what is the proper way to proceed. I need to be able to save for each form anywhere from 1 to 65 types of material on each form.
The text_changed proeprty won't work as it fires on each digit being entered- 123 causes the event to fire 3 times.
Here is the code for the SaveMaterial function from the save button, the StoreMaterial2COL function and the first couple of lost_focus Subs:
Private Function SaveMaterial() As Boolean
Try
' The index of a zero-based collection is Count property minus 1.
Dim iCnt As Integer
iCnt = myMaterialsCollection.Count
iCnt = iCnt - 1
With myMaterialsCollection
For Each aItem In myMaterialsCollection
If iCnt = -1 Then
Exit For
End If
_gblString = CreateGUIDString()
gblConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\JWI\Data\JWI.mdb;Jet OLEDB:Database Password=jWi;")
strData = "INSERT INTO LOLItems (LOLItemsID, LOLIFormID, Type, TextBox, MaterialsID, Units, DateCreated )" _
& " VALUES ('" & _gblString & "', " _
& "'" & _frmGuid & "', '" _
& 1 & "',' " _
& aItem.txtBoxName & "',' " _
& aItem.MaterialID & "',' " _
& aItem.jnts & "',' " _
& Now() & "');"
gblCMD.Connection = gblConn
gblCMD.CommandText = strData
Dim cmd As New System.Data.SqlClient.SqlCommand
gblConn.Open()
gblCMD.ExecuteNonQuery()
myMaterialsCollection.Remove(iCnt)
iCnt = iCnt - 1 'decrement until empty
Next
End With
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
Public Function StoreMaterial2COL(ByRef matID As String, ByRef ctrlname As String, ByRef jnts As String)
Try
'need to check to make sure the txtboxName has not been entered already
'if so then the user is updated the amt and we need to update the
'jnts and not add a new record.
aItem.txtBoxName = ctrlname
aItem.MaterialID = matID
aItem.jnts = jnts
myMaterialsCollection.Add(aItem)
Catch ex As Exception
'Catch ex As System.InvalidCastException
MsgBox(ex.ToString)
End Try
Return True
End Function
'*#*#*#*#*#*#*#*#*#*#*#*#*
'Need to try to make a more generic method of doing this- a control array maybe????
'This is for column 1 Junk Rods
Private Sub txtRodJ_0_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtRodJ_0.LostFocus
StoreMaterial2COL(lblRods_0.Tag, txtRodJ_0.Name, txtRodJ_0.Text)
End Sub
Private Sub txtRodJ_1_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRodJ_1.LostFocus
StoreMaterial2COL(lblRods_1.Tag, txtRodJ_1.Name, txtRodJ_1.Text)
End Sub
Private Sub lblRodJ_2_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRodJ_2.LostFocus
StoreMaterial2COL(lblRods_2.Tag, txtRodJ_2.Name, txtRodJ_2.Text)
End Sub
Private Sub txtRodJ_3_LostFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRodJ_3.LostFocus
StoreMaterial2COL(lblRods_3.Tag, txtRodJ_3.Name, txtRodJ_3.Text)
End Sub
As always any assistance is greatly welcomed.
Larry
|
|
|
|