Asp.net - VB/C# Dynamic Calculations & Referencing?
Jun 11, 2012
I'm developing an app in which there's hundreds of different calculations involved and would like for my app's admins to be able to tweak these calculations by specifying the formulas.For example, my database table contains price and quantity. One of the columns 'X' might contain "(price * quantity) over the past 7 days". How can I allow my app's admins to change the calculation from "7 days" to "14 days"?
Is there some way to make calculations dynamic within VB.NET or do I have to rely on stored procedures and write some code to alter those procedure if a change is needed? What are the best practices in this type of a scenario?Ideally, I would like to use something similar to the "Tags" box used when posting questions on here to bring up the available fields and add mathematical operators in between them to perform calculations. It might be adding more complexity, but would be great if an existing calculation isn't overwritten so that it could be used in building a new formula.
I made a browser and its awesome but i want to reference the browser name so that i can add script to it, I am calling the new browser window "wb" cause that's what it gets named in the script. here is my code. (it labels the tab, the window, and changes the URL text field)
Private Sub wb_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wb.Navigated TextBox1.Text = wb.Url.ToString() Me.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle & " - My Browser"
[code]....
It says "Browse.Name = "wb"" so thats why im trying to call it "wb". I inserted a WebBrowser on the form named wb and then tried to run it and it worked, it labeled the window, tab, and changed the URL field. So i know that the script works. Please help me, I know you guys can solve this, I'm really new at this.So my final question is... What should I call the browser instead of "wb" when I am referring to it in the first script I posted above? I am so confused. How do you refer to an object that gets created dynamically?
i have created a dynamic tabpage and a dynamic tablelayoutpanel inside it then added dynamic textboxes and labels inside the tablelayoutpanel...the thing is , i am having a problem on how to access the value of those textboxes and labels and add them as new columns in the new table(tagpage) in mysql database, i can already create the table in the database but i cant add the new columns in it. heres the code for accessing the values of the labels and textboxes
error: NullReferenceException was unhandled....Object variable or With block variable not set.
Basically i have one TabControl with a form and 2 browsers within one form I have ProBlem To call the dynamic browser to navigate with dynamic Textbox.text
I need to represent the following query using LINQ:
DECLARE @PurchasedInventoryItemID Int = 2 DECLARE @PurchasedInventorySectionID Int = 0 DECLARE @PurchasedInventoryItem_PurchasingCategoryID Int = 3 DECLARE @PurchasedInventorySection_PurchasingCategoryID Int = 0
[code]....
Now, I know that a query in .NET doesnt look like this, this is my test in the SQL Design Studio. Naturally VB.NET variables will be used in place of the SQL local variables.My problem is this: All of the conditions after "WHERE" are optional. In that a query might be made that uses one, some, all, or none of the conditions. V.PropertyID and V.Value can also appear any number of times.In VB.NET I can make this query easy enough by simply concatenating strings, and using a loop to append the "V.PropertyID/V.Value" conditions.I can also make a Stored Procedure in MS SQL, which is easy enough.However, I want to accomplish this using LINQ.
Ive managed to dynamically create a form, and dynamically create a timer, but i have not been able to create the timer on the dynamic form. Specifically, i need to be able to have the timer itself create another form with a timer. (I realize that this would create a new form every interval on the timer, that is what i want to do)
1. A way to add the timer to the dynamic form, and maintain the timer sub on my main form.
2. A way to create the whole thing over (dynamic form and timer) through the previous dynamic form and timer.
I was thinking i could use a collection/array to store the forms and timers, but i'm still having trouble figuring out how to add entire forms or timers into a list. (A timer is not considered a control, so i cant use a controlcollection...)
Heres my code;
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim frm As New Form
[Code]....
*EDIT* Btw, my idea was to use i as a variable that increases every time a form is created, then insert the form into the array, with i as the integer. i just need to know how to create a new form with a different name each time. (as with timers)
I have a DataGridView which displays info from a Database. I need a couple of the columns to be able to do basic calculations such as +, - etc - nothing more complicated really. I am a bit stuck as to how to gte this working.I have tried the code below with no joy:[code...]
I am doing homework, but i've done the work already. My Issue is, I cannot get my program to compile the calculations for the payments properly. Maybe I'm just too tired to see it, but It should be working from my view. Here is what i have so far...
Module MortageCalculatorWK5 'Loan Amount Input Dim LoanAmount As Decimal = 200000
I'm very new to programing and am having problems trying to perform some calculations with a list. I have read in an array into a list with a count attached to each item example: "xxxxxx(intcount)". What I'm trying to do it use two xxxxxx(intcount)'s at xxxxxx(intcount+5) and xxxxxx(intcount+25) and use these two variables to calculate yyyyyy(intcount) but it isn't working. I understand this may be a stupid question but could someone please point me in the right direction.
I have a form that i need to be 100% Dynamic. So it could contain 10 labels maybe 100 who knows.
When you hover over a label there will be a different contextmenustrip to appear for each and every label. So all the contextmenustrips are Dynamic and contain 1 option maybe 2 options even 3 or 4 up to the users settings.
My problem is not creating a handler for when the user clicks on the contextmenustrips options. The problem is knowing which one of the options for that contextmenu was clicked!!
OK, I'm trying to display tooltip text for a dynamic edit box. Well, at least I'm trying to.
On my form, I've got a tool tip control which I've conveniently named ToolTip. My edit box displays OK. But, what I want to do is when the user hovers their mouse over the text box, I want the tool tip to display some text.
I think there are two problems that I'm having. I'm not convinced that I'm properly addressing a dynamic text box name. Ideally, I would want to be able to refer to the text box (but using a dynamic variable that will contain the prefix of the name). To hardcode, I would want to be able to achieve (not in this example but in theory): ABCDEFGt_0300.Text = "hello"
Dim controllerName as string = "ABCDEFG" Dim t_0300 As New TextBox() Me.Controls.Add(t_0300)
i used this code to assign the brand dbs to a value of 200
[code]Private Sub xModelComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xModelComboBox.SelectedIndexChanged If xModelComboBox.Text = "DBS" Then
I have to use some calculations now and then and sometimes those will give me inf, and sometimes they work, this makes my app very inaccurate...Now i dont know what is causing this, im not dividing zero so far i can see..
(3 + Math.Sqrt(5)) ^ ...
It works for single numbers, But how would i retrieve the ?double? of bigger numbers without getting INF?With bigger numbers i mean really big, like 1477014138.
i want to add calculations in 1 private function I have a textbox named lbldisplay.text when i enter a number.. the number is shown as a string so.. -private number1 as string when i press the button "+", "*", "-", or "/" the number1 must return into a double. So the number in the textbox is now a double.. so for example i press the + button, and i need to fill in a new number.. but this new number is also a string!
I cannot figure out why my calculation is not working. I am doing for 1 to 12 and it gives me 12 inputs but counts my entries as 13? What am I missing. If I change it to 0 to 11 same thing. I am not sure what the issue is, but I cannot see it, and am not sure where to look.I need to end up with 12 cycles through and intEntries to be 12.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'initialize accumulator Dim decEntries As Decimal[code].......
As part of an assignment, I need to add numbers which are displayed in a rich text box. The numbers are read from a text box. The user needs to be able to input the numbers as many times as possible. Since, the numbers all come from the same text box, I am unsure how to retain the old information and add the new information to it.Since I am not really able to make my point clear, I attach this picture: RTB.PNGAs you can see, I also have a problem with the heading repeating itself. Is there a way of forcing it to only appear the first time?Here is the
Private Sub AddMoreItemsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddMoreItemsToolStripMenuItem.Click 'Retrieve number from textboxes
I got a program I am working on. It does some calculations using quantity and price in such. Heres the calculation module. Private Sub calculations() If AdultsizeRadioButton1.Checked = True Then adulttotaldecimal = quantityinteger * adultpricedecimal * hoursinteger ElseIf ChildsizeRadioButton2.Checked = True Then childtotaldecimal = quantityinteger * childpricedecimal * hoursinteger [Code] .....
Ok, everything has worked when I display the information.... up until the accumprofitdecimal variable. When i display that value its NOT what it should be. For instance i'm putting in a quanity of 1 and an hour of 1 for an adult then for a child, the extended price comes out properly as $2.15 now the code accumprofitdecimal += extendedpricedecimal SHOULD add the extended price (2.15) to the accumulative total. but when i display the accum profit total it shows a number that makes zero sense... is accumprofitdecimal += extendedpricedecimal not correct code?
I have an older program that I wrote some time ago in VB then late updated for VB.Net. The program calculates the ephemerides of comets based on orbital elements downloaded from the Minor Planet Center website. I am now trying to make an iPhone/iPad application using the same idea and the same calculations. Unfortunately I am too new at objective-c that trying to convert the extensive calculations is proving quite difficult for me.
I am doing a diet program in VB.net and I have 3 forms which have food and drinks as text boxes which can be selected by the user! I have coded them to be sent to list boxes on another form called 'results'. How can I set it up so what is selected on each form is added to a list box then adds up the calories etc. form what the user selects. I have made a calculate total button to add whats in the list boxes and I need to show the results to the user! How would I go about coding how to do this?
I was working with a calculator i made.. and then i was thinking of making all my calculations to be displayed in the listbox..Here is my program for the calculator..
Public Class Form2 Dim Nm1, Nm2, nnn As Long Dim Opr As String Dim FF As Boolean = False
I am unable to get the correct calculations out of my variables. If I input say fgh2 and enter 5 for monthly sales everything displays fine. enter fbd2 and 5 for monthly sales again everything is fine I get a result of 10 but as soon as I deviate from that formula like ftp1 and 3 in the monthly sales textbox it comes back as 13 in the newCarLabel when it should be 3
Option Explicit On Option Strict On Option Infer Off Public Class MainForm 'global variables
i have two date time values (dd/mm/yyyy) <== This comes from the database the second one come from the NOW function in VB, also in the form of (dd/mm/yyyy) how do i compare the two values to find the difference in the time, eg (1 day and 4 hours)
I have a datagridview which as several rows read from an access database which I can not alter. Column 4 of each row shows the date of the last service call. I would like to have a calculated column showing the difference in days between the date in Row1 and the date in row 2, the date in row 2 and the date row 3 etc.. I have exported the datagridview to excel and have set the calculated column it works ok, but is is possible to do this from within VB datagridview
Im creating an application that allows me to enter a product with a cost. I want all the costs to be saved in an array and then calculate the total cost and display it in a label. I looked for hours in my textbook and cant seem to get this part.
I need a little guidance in the right direction to help with using data from a dataset in calculations. I've watched the "How Do I" Series and it was very helpful in setting up the relations and tables. I have setup a couple tables to hold values that won't be updated and the user will never see. Lets say I have 5 columns, ColmnA to ColumnE, and the row count is variable. What I can't seem to find is an easy way to loop through using the variables. As an example, Lets say the equation would be outputted to a textbox:
textbox1.text=row1(ColumnA*ColumnB+ColumnC^ColumnD-ColumnE)+row2(ColumnA*ColumnB+ColumnC^ColumnD-ColumnE)+etc to end of rowcount
Does anyone know if a good tutorial to point me in the right direction or a code snippet that may get me started to follow the logic? I'm using VS2010Express with a SQLExpress database if that helps.
I am working in Visual Basic 2010 Express and have a table with 3 columns created using a SQL dataset called 'test' if you like.The table columns are called A B and C If someone enters a value of 10 in A and 15 in B, is it possible for column C to automatically add them up and come up with 25? - if so how do I start?The above is only a simple example of the problem I have, but once on the right track I am sure I can apply the same logic to the table I actually have?