Click here to Skip to main content
16,006,348 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Bind a data set in an HTML table Pin
Tyquaun Hunter31-Jul-06 4:28
Tyquaun Hunter31-Jul-06 4:28 
GeneralRe: Bind a data set in an HTML table Pin
MalikRizwan31-Jul-06 18:55
MalikRizwan31-Jul-06 18:55 
QuestionRadix Sort Pin
faaisaal26-Jul-06 23:46
faaisaal26-Jul-06 23:46 
AnswerRe: Radix Sort Pin
Guffa27-Jul-06 1:16
Guffa27-Jul-06 1:16 
QuestionCalculation based on a formula entered in a text box Pin
RichardBerry26-Jul-06 22:24
RichardBerry26-Jul-06 22:24 
AnswerRe: Calculation based on a formula entered in a text box Pin
Dave Sexton26-Jul-06 22:54
Dave Sexton26-Jul-06 22:54 
GeneralRe: Calculation based on a formula entered in a text box Pin
RichardBerry26-Jul-06 23:42
RichardBerry26-Jul-06 23:42 
GeneralRe: Calculation based on a formula entered in a text box Pin
Dave Sexton27-Jul-06 1:06
Dave Sexton27-Jul-06 1:06 
Ah, I see now. I assumed that the textbox would only hold the value "6.25" and a combobox or another control would hold the ADC_Value (is the 424 a constant?). Then what you would have is something like...

'an event to call the function

Private Sub btnCalc_Click.....
'get the ADC value and add it to a label
Label1.Text = CStr(GetADC(Textbox1.Text, cboADC.Text)
End Sub


'the variables used in this function could be stored in a database 
' and called when necessary. the "Value" argument is the 6.25 from the
' textbox.
Public Function GetADC(ByVal Value as Double, ByVal ADC_Value as Double) As Double

Dim dblADC As Double 'variable to return

dblADC = Value * (ADC_Value - 424) 'do the calculation


Return dblADC 'retun the result

End Function


If the 424 is also a variable, it could also be stored in a database and added as an additional argument to your function, or you could create an overloaded function if it's not always required.

Using this kind of method your users won't have to remember the formula as you build it for them. All they'd have to change is the value in the textbox which would make it far more user-friendly. Also, you could then validate in code that the value supplied in the textbox (6.25 in your example) was in fact a valid datatype which will prevent your app from breaking and generally improving it's stability. See where I'm going with this?

At the end of the day tho, it's your project and your clients. I'm only trying to give you another perspective on how to tackle it. From my approach, the class you'd write would be more of a "Formula Engine" which builds the formulae that users would need without them having to remember it, flexible enough to accomodate variations on the formula (using overloads, possibly) but still robust enough that your results are reliable.

There are a couple of ways you could go about this... interesting. Thanks. Smile | :)
GeneralRe: Calculation based on a formula entered in a text box Pin
RichardBerry27-Jul-06 2:40
RichardBerry27-Jul-06 2:40 
GeneralRe: Calculation based on a formula entered in a text box Pin
Dave Sexton27-Jul-06 4:55
Dave Sexton27-Jul-06 4:55 
GeneralRe: Calculation based on a formula entered in a text box Pin
RichardBerry27-Jul-06 22:18
RichardBerry27-Jul-06 22:18 
AnswerRe: Calculation based on a formula entered in a text box Pin
darkelv27-Jul-06 2:28
darkelv27-Jul-06 2:28 
GeneralRe: Calculation based on a formula entered in a text box Pin
Dave Sexton27-Jul-06 4:51
Dave Sexton27-Jul-06 4:51 
QuestionCould I have some help with Sql statement. Pin
MickYL26-Jul-06 22:22
MickYL26-Jul-06 22:22 
AnswerRe: Could I have some help with Sql statement. Pin
Guerven26-Jul-06 22:59
Guerven26-Jul-06 22:59 
GeneralRe: Could I have some help with Sql statement. Pin
MickYL26-Jul-06 23:14
MickYL26-Jul-06 23:14 
GeneralRe: Could I have some help with Sql statement. Pin
Colin Angus Mackay27-Jul-06 2:22
Colin Angus Mackay27-Jul-06 2:22 
AnswerRe: Could I have some help with Sql statement. [modified] Pin
MickYL26-Jul-06 23:23
MickYL26-Jul-06 23:23 
GeneralRe: Could I have some help with Sql statement. Pin
Colin Angus Mackay27-Jul-06 2:24
Colin Angus Mackay27-Jul-06 2:24 
GeneralRe: Could I have some help with Sql statement. Pin
Guerven27-Jul-06 16:27
Guerven27-Jul-06 16:27 
Questionhelp regarding designing rich user interface Pin
ps_prakash0226-Jul-06 22:03
ps_prakash0226-Jul-06 22:03 
QuestionCombobox In DataViewGrid Control Pin
riyaz_786_p26-Jul-06 21:51
riyaz_786_p26-Jul-06 21:51 
QuestionHowTo copy entire folders with contents to a different folder? Pin
Zaegra26-Jul-06 21:12
Zaegra26-Jul-06 21:12 
AnswerRe: HowTo copy entire folders with contents to a different folder? Pin
hannesHTG28-Jul-06 1:30
hannesHTG28-Jul-06 1:30 
QuestionReversing Bit Order of a Byte Pin
RichardBerry26-Jul-06 20:53
RichardBerry26-Jul-06 20:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.