VS 2010 Average Time In LinQ?
Apr 9, 2011
I need help on how can I transfer a query from Access to LinQ that calculate the average in time per transaction during a given date.the working Access query is:
Avg(DateDiff("s",CVDate(Format([start_time],"hh:nn:ss")),CVDate(Format([finish_time],"hh:nn:ss")))) AS Expr1, Format([Expr1]3600,"00") & ":" & Format(([Expr1]60) Mod 60,"00") & ":" & Format([Expr1] Mod 60,"00") AS format
How can I port this to LinQ?
View 1 Replies
ADVERTISEMENT
May 3, 2009
I need a start date, a Total time passed until now, an average time per step, and a estimated time to finished. How can I do that? Also, I can close the application and when start up again I want to get the time counters as the last time, so How can I store that data is normal txt file (I say txt to take advantage of the ini app file which is a txt).
View 1 Replies
May 3, 2010
I tried the following code:
Dim T5NHCEDCavg As Double
qry = From employee In empList
Where employee.HCEDC = False And employee.X5 = False _
Select employee.DCFSA
T5NHCEDCavg = qry.Average
But I'm getting a design-time error that says "Overload resolution failed because no accessible 'Average' accepts this number of arguments." I realize that I'm missing an overload here, but I'm not sure what to use or how to do this. I'm pretty new to LINQ. I've got a dataset in memory that I'm querying, and there is a double-precision property DCFSA, of which I'm trying to get the average based on my query above.
View 4 Replies
May 14, 2012
I wrote the following generic LINQ extension for calculating weighted average in Visual Basic 2010:
<Extension()>
Function WeightedAverage(Of T)(ByVal source As IEnumerable(Of T),
ByVal selectorValue As Func(Of T, Integer),
ByVal selectorWeight As Func(Of T, Integer)) As Double
Dim weightedValueSum As Double
Dim weightSum As Integer
[Code] .....
How can I call this function as an Aggregate function of another LINQ query? I tried it in the following way:
Dim q1 = From jd In oContext.JobDatas
Where jd.Year = 2011
Select jd
Dim q2 = Aggregate num In q1 Into WeightedAverage(num.AvSalary, num.NumPosHolder)
The Visual Basic 2010 editor is telling me that the second query (q2) of the following code is not valid statement. On the comma between the first an second argument it's saying: ")" required.
View 1 Replies
Apr 10, 2011
I have written a stopwatch program that has several trials. Each trial is recorded in minutes and seconds in its own label. I would like to find the average time of the trials. I do not know where to start.kobbe
View 4 Replies
Dec 8, 2011
I need to figure out the time between timestamps and then average that time by the number of timestamps. Not sure how to go about this...
View 13 Replies
Jun 15, 2010
I want to include an average in a column where the average ignores zero values in a report cell where the column may have
17
19
0
[code].....
I want 16, not 11 so (17 + 19 + 12 + 13 + 19) / 5 not (17 + 19 + 0 + 0 + 12 + 13 + 19) / 7 Something like this if it would work.
=SUM(Fields!fieldname.Value) / Count(iif(Fields!count_cycle_per_hour.Value >= 0,Fields!fieldname.Value,0))
Essentially just average everything in the column NOT a zero?
View 4 Replies
Apr 20, 2010
I just upgraded a project from VB 2008 to VB 2010. Before, the project did not use LINQ. I have started implementing it. So, I have updated the target framework from 2.0 to 3.5, and added a reference to System.Core, and imported the namespace System.LINQ to the entire project and also imported System.Data.LINQ into the form I'm working with (because it was not available in the list for Imported Namespaces in the references tab).
It's not throwing any errors now, but my IntelliSense is not working for LINQ stuff.
For example... I write this:
[CODE]....................
Then, if I type S. on the next line, the IntelliSense doesn't grab what it should for S (Only get Equals, GetHashCode, GetType, ReferenceEquals, and ToString, instead of the options I should get like Count, First, FirstOrDefault, etc...). If I Type S.First. then its the same thing, no IntelliSense that lists the available fields for S, just the standard options (Equals, GetHashCode, GetType, ReferenceEquals, and ToString). I should be seeing my column names in my table when I type S.FirstOrDefault.
So any ideas what is going on? When I type the code, for example, MessageBox.Show(S.FirstOrDefault.FirstName), it works perfectly. But it doesn't change the casing of the text (so it would read s.firstordefault.firstname) and no intellisense while doing it. But no errors. BTW - Everything works perfectly when creating a NEW VS 2010 application, it's just my projects upgraded from Visual Basic 2008 that have this issue.
View 2 Replies
Sep 8, 2009
I'm working on a function to return a exponential average and there are a lot of examples of exponential moving averages but they all start with a moving average that is just the mean as a lead in to calculating the continuing moving average. I needed just a exponential average of a value set. After Googling my Bing off I still haven't seen anything so here is my attempt at a basic exponential average. Is this correct? Are there any errors? I have seen some text about adding a smoothing value to change the curve of the exponential average but not how that would be implemented.
[Code]...
View 5 Replies
Mar 26, 2012
I put comments on the average output since I kept getting error messages about that. My out keeps saying:
Maximum value: 33
Minimum value: 33
what am I doing wrong?
Option Explicit On
Option Strict On
[Code]...
View 2 Replies
May 10, 2011
I'm in a computer science class, and we are writing simple programs using Visual Basic 2008. I am really inept when it comes to this, as I have never done it before. I need to write a program that: "Asks the user for 5 numbers and computes the average. It then displays the average with an appropriate message before the average."
I have been really close with this, but I can't get the numbers to add up, then divide by 5, and display a pop up message.
View 13 Replies
Apr 29, 2012
Basically I need to remove Listbox1 items that are less then average, but its giving me:
System.ArgumentOutOfRangeException was unhandled
Message=InvalidArgument=Value of '9' is not valid for 'index'. [Code]
View 2 Replies
Aug 18, 2011
I'm working with an API, for this I'm using this particular call: [URL]
If i use this, I will get all the .price values:
For i = 0 To .bets.Length - 1
With .bets(i)
Print(.price)
End With
Next
Can I calc the average .price value? I will need to sum all the values as well.
View 8 Replies
May 13, 2011
"I need to create a program that will allow the user to enter in 10 test grades from a class. I need to store these grades into an array, and use a loop to add up the total. Then I'll need to output the average, and the letter grade for the average using:
90 - 100 A
80 - 89 B
70 - 79 C
60 - 69 D
Below 60 F"
That's all it needs to do. Here is some code that shows you that the only thing I know how to do is (allow the user to enter in 10 test grades from a class.) The rest I'm so lost on and have a crappy instructor. This assignment is due tomorrow, but the instructor is not available over the weekend.
Here is my This is all I have:
Dim MyNumbers(9) As Integer
Dim Total As Integer
Dim i As Integer
[Code]....
View 9 Replies
Sep 22, 2009
I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens.Certainly in a For Each loop, the query would be enumerated.What's the rule of thumb to follow? I don't want to accidentally enumerate over my query twice if it's a huge result.
For example, does System.Linq.Enumerable.First enumerate over the whole query? I ask for performance reasons. I want to pass a LINQ result set to an ASP.NET MVC view, and I also want to pass the First element separately. Enumerating over the results twice would be painful.It would be great to turn on some kind of flag that alerts me each time a LINQ query is enumerated. That way I could catch scenarios when I accidentally enumerate twice.
View 3 Replies
Jul 12, 2011
I'm trying to filter out the time which is greater than 8:00 am and store it in array . Can anyone give me some suggestion?[code]
View 1 Replies
Feb 22, 2012
I as seeking to move 10 file every 10 minutes from one folder to another using .NET (vb c#) I am was thinking that i could of achieve this with LINQ query, but i cant get my head around this would there be a solution with LINQ or otherwise that can select the last 10 files form or top 10 files. so that i can move only these files from Directory1 ( the big pool of files) into director 2 ( a smaller more manageable pool of files).If all fails- then i wll manually have to copy or cut to at a time.
View 1 Replies
May 17, 2009
I need to have a query which list all the user according to the date value in the database. Problems is this, in the database the date format is 5/5/2009 4:30:12 but I want to compare with 5/5/2009. I think the value of the based date is 5/5/2009 12:00:00 and that's why I couldn't query it.
The query is something like
dim db = new databcontext
dim user = from u in db.datacontext where u.signUpTime = 5/5/2009 select u.
View 1 Replies
Mar 16, 2009
I have an untyped dataset returned from my WebService. The user wants to dynamically construct a query referencing tables and columns and specifying values to test for.I have looked at Lambda Expressions and the Expressions.Expression Namespace. I think these provide the answer I'm looking for, but I'm not certain how to go about contructing the linq expressions to extract the datarows I'm looking for.
I plan on limiting the result to one datatable that the query will result in and i"ll provide the joins from the user's constructs.For a simple example I have a DataTable with (n) rows called "Table", and in it there is a computed column called "b_IsActive" that has the expression "Convert(IsActive, 'System.Boolean')". The user wants to retrieve all rows in "Table" where field "b_IsActive" is true.
View 5 Replies
Mar 27, 2011
I'm writing a report scheduler that is somewhat of a clone to the backupexec scheduler and the layout can be seen in post #10 here: [URL]..It works great and saves/edits/deletes records just fine, but now i need to compare those records one at a time in a windows service that i'm writing in order to trigger automated report creation and emailing - i already have the report and i already have the code for the emailing, i'm just looking for the most efficient way to loop through the table (that i've pulled in to a dataset) and compare its records with the current date and time - if true, the event fires.
[Code]...
1stSun, 2ndSun etc are bit fields, time is a datetime, and the remainder are varchar. My service checks the database every thirty seconds.The english version of what i'm trying to do is "Connect to the database, grab the entire table (it will always only have 5-6 entries max, so i felt 30 second sweeps was okay), and If today is the 1st Sunday of the month, and it is currently 11:00:00 a.m. (could be any day or time, this is just an example) - loop through the dataset to identify if any records match the time field or greater - if they do, fire the report
View 2 Replies
Nov 3, 2011
Here are my questions concerning VB 2010 Express:
1. I've registered my VB 2010 Express, will it still expire?
2. Will the applications I made using VB 2010 Express expire after some time?
3. Is it OK to write my code in the designer.vb file? I don't know why, but when I started writing my application it took me to the designer.vb instead of form1.vb code.
4. I've been working on an application for a week now, but suddenly I can no longer access my Design View(Shift-F7). All my codes are written on the [form name].Designer.vb. I can still view my codes but I cant access my form layout. On the solution explorer, my forms no longer have the 'form icon'. When i press Shift-F7 nothing happens. Right-clicking the form on the solution explorer doesn't show 'View Designer' option. How can I fix this?
View 5 Replies
Sep 19, 2010
Checked out the video on MS website by Beth Massi and downloaded the project.
One query she uses this statement,[code...]
I'm I missing a reference or something? This is an Access DB, does that make a difference?
View 7 Replies
Nov 16, 2011
In proper sql my query would be something like:
select c.id, c.name, count(i.id)
from cats c, items i
where c.id=i.catid
[code].....
View 1 Replies
Aug 6, 2011
THE CODE IS :
var query1 = ((from c in dt.AsEnumerable()
orderby c.Field<int>("1") descending
select c));
var query2 = (from c in query1.Take(10)
select c);
[Code]...
View 1 Replies
Sep 18, 2010
I need to create an application that is able to modify the XML elements value.I have an XML file which was created by another to be used for flash movie which has the following layout:
<?xml version="1.0" encoding="utf-8"?>
<games>
<game>
<gameName>Cowboy</gameName>
[code]....
As you can see there is this string "™" on <gd02>. My question is, whenever I save the file, the code changed to "TM" which is fine for most cases. But I need it to stay the same because apparently flash will not display the superscript "TM" if not using the code. How can I do this?
View 6 Replies
Jul 4, 2010
I have an array of approximately 1000 classes. All of these classes must have one of their properties changed to the same value. I need this to be as optimized and fast as possible.
Would LINQ be faster than a for-loop? Any other ideas for faster execution?
View 11 Replies
Jan 18, 2012
Is there a way to use LINQ to filter a DataTable for rows that contain particularcharacter but in a "Accent Insensitive" way? Search over the web I came with something like this:
Dim dt As DataTable = CType(BindingSource1.DataSource, DataTable)
Dim SearchVAlue As String
SearchVAlue = "e"
[code].....
View 7 Replies
Mar 13, 2012
I am trying to read information from a text file(.txt) using LINQ.I can't use a list box of predefined continents that someone can click on and it will bring up data from that continent.It will work if I let the countries fill the list box from the text file but then if I have two people from England my list box will display England more than once.For example my UN.txt file that is in my debug folder: [code] So I guess I have two different questions: 1. Is there anyway to stop the duplication of the continents as shown above? Can I pre-fill the list box with the continents and not have to fill it from what's in the data file?
View 14 Replies
Dec 2, 2011
I'm having trouble figuring out what to do with the bolded part, when there are no nodes to return.If there are no image tags inside the <images> tag, i get an "Object reference is not set to an instance of an object".I have been searching and searching for an answer but can't find one.
Dim orders = From o In xmlLinq.Descendants("order")
Select New With { _
.orderID = o.Attribute("id").Value, _
[code].....
View 2 Replies
Mar 30, 2012
I'm really struggling with this. I have two XML files. The first one has items, and then sub elements for properties:
[Code]...
View 3 Replies