|
dim Query1 = (From t1 in context.mytable where conditions1 select t)
dim List1 as list(of mytable) = (from t1 in Query1 where conditions2 select t1).toList
i need to declare Query1 variable and list1 variable before and after to use them
Dim query as ????????
and after to use : query1=From t1 in ......
so how i can declare Query1 ?
Thank you.
|
|
|
|
|
With Visual studio 2008 you can use anonymouse types. Further reading Anonymous types[^]
As your first query is consumed only by the second query I would stick with using an anonymous type. Personally I feel outside of LINQ statements they shouldn't be used.
If you feel the need to have a type declared you can choose either a IEnumerable(of t) or IQueryable(of t)
This article gives you hints when you should each type IQueryable vs IEnumerable[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
i use visual studio 2010 /sql server 2008r2.
IEquerable(of t) ---- doesn't work ( give some errors on second query)
IEnumerable(of t) --- works fine when i declare both Query1 and list1 as Ienumerable(of t).
thank you.
|
|
|
|
|
I had no problem executing a similar query to the one I advised you.
I would suggest that you send the Actual query (including the actual types that you are returning) that you are trying to execute and the error message that you are getting and we should be able to solve your problem.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Well, I'm making an autoupdater/autopatcher, and everything's going swimmingly, but I've recently reached an impasse, I've noticed, that if there's a need to overwrite a file, SharpZipLib would actually return false, and not unzip a single thing. Anybody got any info on why this is, or maybe some example code on how to use it?
modified 21-Nov-11 18:01pm.
|
|
|
|
|
Little bump, if that's OK.
|
|
|
|
|
I have 1 tabcontrol with 3 tab (tab1,tab2,tab3)
each tab have 1 datagridview (datagridview1,datagridview1,datagridview3)
I add 1 button and want to export data from datagridview in the tab that I focus on. (I don't want to add 3 button for each tab)
How can I do that.
Thank you.
|
|
|
|
|
Take the tabcontrol, get the active tab and search the controls collection for a DataGridView, that will then give you a reference to which DGV is currently displayed.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
Dim currentDGV As DataGridView = getActiveDataGridView()
Debug.WriteLine("Active DGV name is: " + currentDGV.Name)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Function getActiveDataGridView() As DataGridView
For Each cont As Control In TabControl1.SelectedTab.Controls
If TypeOf cont Is DataGridView Then
Return cont
End If
Next
Return Nothing
End Function
|
|
|
|
|
It's working.
Thank you very much.
|
|
|
|
|
njtd wrote: It's working.
I should hope so!
|
|
|
|
|
I am not able to get the right value for radians to degree conversion by the following code. It gives wrong value plz help.
ReadOut.Text = System.Math.Sin(Val(ReadOut.Text)) * (180 / System.Math.PI)
|
|
|
|
|
To convert radians to degrees you use
double degrees = (180 / Math.PI) * radians;
So you should try
ReadOut.Text = Convert.ToDouble(ReadOut.Text) * (180/Math.PI);
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thanks anyways. I tried the methods but they don't work for me.
|
|
|
|
|
I tried the below code. for radian 0.989 to degree it is giving 56.2xxx
ReadOut.Text = System.Math.Sin(Convert.ToDouble(ReadOut.Text)) * (180 / System.Math.PI)
|
|
|
|
|
Your problem is the Math.Sin code. You don't need to calculate Sin at all. Do it just as I explained.
Convert.ToDouble(ReadOut.Text) * (180 / System.Math.PI)
With your example it should result in 56.67 (to 2 decimal places).
That is all you need.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
My Readout.Text takes a value, then it finds Math.Sin(Convert.ToDouble(ReadOut.Text)) and gets the radian value, say 0.989 for sin(8) then if degeree is selected then it performs Math.Sin(Convert.ToDouble(ReadOut.Text)) * (180 / Math.PI) which is giving 56.6 for 0.989 * (180 / 3.1415) instead of giving 0.13917
If radians RadioButton is Checked
ReadOut.Text = System.Math.Sin(Convert.ToDouble(ReadOut.Text))
If degrees RadioButton is Checked
ReadOut.Text = System.Math.Sin(Convert.ToDouble(ReadOut.Text)) * (180 / System.Math.PI)
If Gradians RadioButton is Checked
ReadOut.Text = System.Math.Sin(Convert.ToDouble(ReadOut.Text)) * (200 / System.Math.PI )
|
|
|
|
|
When the user enters something in Readout textbox what is it they are entering, is it the angle in degrees or what ?
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
They are entering simply a number.for eg., 8 is entered and if degree radio button is checked then it does the below code
ReadOut.Text = System.Math.Sin(Convert.ToDouble(ReadOut.Text)) * (180 / System.Math.PI)
first it finds the Math.Sin(Convert.ToDouble(ReadOut.Text)) and gets the Sin value for 8 in radians and then it multiplies with (180 / Math.PI) to get the degrees and the new value is converted to string and displayed in the same TextBox. The whole process is done in a single statement
|
|
|
|
|
I think you need to state why would they enter 8, what does 8 represent, and if they enter 8 and the degrees radiobutton is checked, does it mean that they are entering the value in degrees, or are they expecting the results in degrees?
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
When Degrees RadioButton is Checked, they are entering value in degrees.
|
|
|
|
|
The radian value of Sin(8) is 0.989 if it is multiplied with (180 / 3.1415) it is 56.6, but all software and hardware calculators are giving 0.139173.
In fact all calculators are giving 0.13917 as the degree value dor sin(8).
180 / Pi is approx. 60. and 60 * 0.989 is approx 56.6., but how come all software and hardware calculators are giving 0.139173 as the answer.
|
|
|
|
|
I think you are getting confused between Sin and radians.
The Sin of 8 degrees is 0.139173.
8 degrees converted to radians is 0.1396 radians.
The sin of 0.1396 radians is 0.139173, which matches the Sin of 8 degrees.
The sin of 8 radians is 0.98936, and 8 radians = 56.67 degrees.
With a calculator, if the Degrees radiobutton is selected, then the number the user enters is in degrees, and if the Radians radiobutton is selected the number they enter is in radians. So, if degrees is selected and the user enters 8, then the user means 8 degrees.
What you are doing is getting the sin of 8 Radians and converting it to degrees, then comparing that to the sin of 8 degrees. I hope you see now.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thanks, I Changed the code.
If the Degree RadioButton is Checked the the user is entering value in degrees. so,
ReadOut.Text = System.Math.Sin(Convert.ToDouble(ReadOut.Text) * (System.Math.PI / 180))
gives the right answer
|
|
|
|
|
How to search for a string in a textbox in vb 2010
|
|
|
|
|
You can use the Contains extension method of your string, e.g:-
bool doesContain = yourString.Contains(searchString);
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|