![]() |
|
[.NET] 95 percent done with this program - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] 95 percent done with this program (/showthread.php?tid=5743806) |
95 percent done with this program - SIM-1895121 - Oct 27, 2017 I am currently working on a project called TG automotive. It is a simple form with pretty basic calculations. I have the program running flawlessly except for the validation. I am supposed to have a function that tests to make sure inputs are numeric and not negative. I have written the function, i just cannot seem to figure out how to actually implement it in the program. Any tips or suggestions greatly appreciated. The ValidateInputs() is the function i created that i need to implement. Here is the full code. Code Public Class Form1RE: 95 percent done with this program - CoderEX - Oct 27, 2017 Have you tried implementing it into the textbox text change event? Note: I did not look through the entire code. RE: 95 percent done with this program - SIM-1895121 - Oct 27, 2017 (Oct 27, 2017 09:19 AM)CoderEX Wrote: Have you tried implementing it into the textbox text change event? So i would be adding it to Parts function and the Labor function? I cant figure out correct syntax for referencing it while still keeping the currency format. This is where the text boxes get converted. Edit: By changing it to a procedure i can simply call it using ValidInputs() wich works, however the assignment is asking me to use it as a function. Code Function Labor() As DecimalRE: 95 percent done with this program - He B TeMy - Oct 27, 2017 You're not calling your ValidInputs() method anywhere, either you call them on the Button that you are proceeding with the validation or you handle both textbox's textchanged events and handle it that way. RE: 95 percent done with this program - CoderEX - Oct 27, 2017 Refer to this link to see how to use control events (specifically textbox controls): https://youtu.be/Z4SQwEVwjJg You will be implementing the ValidInputs() function into the event. RE: 95 percent done with this program - SIM-1895121 - Oct 27, 2017 Very useful video, thank you for that. I seemed to have solved my issue, well atleast as good as its going to get. Would anyone be interested in possibly tutoring me in vb.net for this semester? I work full time and dont have time to make it to my professors office. I have like 4 large assignments left. At no point would i be asking anyone to do my homework, just provide support for when i screw up. I can compensate depending on what you want. PM me if so RE: 95 percent done with this program - gigajew - Oct 30, 2017 Non-negative integers would imply unsigned integers "The value of an item with an integral type is the mathematical integer that it corresponds to. Integral types may be unsigned (capable of representing only non-negative integers) or signed (capable of representing negative integers as well)." - Wikipedia Here's an example solution (from Stackoverflow user Isak Savo) modified for decimals: RE: 95 percent done with this program - 0xDEAD10CC - Oct 31, 2017 Instead of throwing exceptions you should implement a TryParse(). RE: 95 percent done with this program - Dofeus - Oct 31, 2017 make a parameter for your ValidateInput method. Code Function ValidateInput(Byval input as Integer) As Booleanthen if you are going to use it: Code If ValidateInput(txtParts.Text) ThenRE: 95 percent done with this program - 0xDEAD10CC - Oct 31, 2017 (Oct 31, 2017 10:00 AM)Dofeus Wrote: make a parameter for your ValidateInput method. You define the function to take an integer yet you pass in a string... LOL. Why not ByVal the string and ByRef an int to return a boolean and return the result in the reference param passed in the way TryParse() methods work? |