Creating Separate Functions To Clean Code Without Altering It?
Jan 24, 2012
I have created an application that would calculate NFL rating based on statistics pretty much everything is correct but how would i seperate the public function into multiple private one's while still performing the same actions? Example, Private Function CPA( Rather than having a single public function witch performs every step needed
Here's what i have
Dim intcomps As Double
Dim sngInts As Double
Dim sngAtt As Double Dim intcomps As Double
[Code].....
View 1 Replies
ADVERTISEMENT
May 17, 2012
I did a super simple calculator with ASP.net with five buttons: add, subtract, multiply, divide, clear. There are five separate functions for each button's click event. For example: Sub addfunction(ByVal s As Object, ByVal e As EventArgs)If Not IsNumeric(input1.Text) Or Not IsNumeric(input2.Text) Then resultLabel.Text = "You entered an invalid or missing number"
[Code]...
How might I be able to combine all 5 of these functions into one? So for example, all the onclicks will refer to the same function, but will somehow be able to determine which button was clicked? I forget a lot of VB.net from a year.
View 2 Replies
Mar 4, 2009
When I code in PHP I usually keep my functions in a separate file functions.php, I am going to write a small function in VB, is it ok to keep all my functions and subs in the 1 file linke in PHP? will they be available in all my form code?
View 3 Replies
Aug 18, 2011
As I develop code, I often want to unit test some of the building blocks of a class even if they are normally private. If my unit tests are inside the project, I can use "Friend" to accomplish this and still keep the functions private for normal use. But I would rather move my NUnit tests into their own separate project(s). How do I achieve the effe vb.net 2005?
View 11 Replies
Mar 15, 2009
As I develop code, I often want to unit test some of the building blocks of a class even if they are normally private. If my unit tests are inside the project, I can use "Friend" to accomplish this and still keep the functions private for normal use. But I would rather move my NUnit tests into their own separate project(s).
View 3 Replies
Nov 1, 2011
I am making and antivirus in visual studio 2010 using VB.Net using MD5 Hasher algorithm. Plz help me how can i clean a file infected with virus? Note that byy "Clean" i mean repair the infected file to a secure stage, "Remove" is used for deleting the infected file (which i already done.One more thing that i have done the selection of a custom folder or drive, but how can i code behind the "full scan" button. means when user cllick full scan button, it automatically scans full my computer drives including usb flash drives (if attached".
View 9 Replies
Nov 25, 2008
I found this code to rotate a picture online somewhere and made some changes and it works beautifully. My only problem is how much memory it uses. Does anyone see a way for it to use less memory?
Code:
Private Sub RotatePicture(ByRef bm_in As Bitmap, ByVal angle As Integer)
' Copy the output bitmap from the source image.
[code].....
View 1 Replies
Sep 10, 2011
I've got Visual Studio 2010 and I am looking to clean up my code technique, since I've taught myself and now I'm taking classes.
I'm trying to use a For...Next Loop so that I can fill a text box with sequential numbers. For some reason, all I can get in the text box is the last number and I feel that at this point I'm probably overthinking it...
All I want is on the button push the text box shows:
Here's what I have:
CODE:
Once I grasp this simple concept, I can move on to the actual challenge ahead of me, but I really want to know the proper way to handle this with out going all spaghetti code.
View 7 Replies
Aug 16, 2011
I have been using adodb as my database connection to mysql from vb.net, now I want to know if i can create a query string with 2 separate query like so:
vb
dim querystring as string
querystring="update table1 set columname = 'value' where columnname='value';update table2 set columname1 = 'value1' where columnname2='value1'"
Then I can include that to my recorset:
vb
dim rs as adodb.recordset
rs = new adodb.recordset
rs.open(querystring,con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
View 2 Replies
Mar 2, 2010
I am trying to create a function to clear my form. The code is as follows:
Private Sub resetForm()
'Set an integer to loop through the controls
Dim x As Integer
[code]....
it works when I set the type of control as textbox but when I try to do the same thing with radioButton and make it's checked proporty = to false I get checked is not a member of 'system.windows.forms.control'
View 5 Replies
Aug 15, 2011
I have produced some VBA in Access that creates a spreadsheet.I have also created an SQL query that retrieves records from an Access table.I have 48 tables (each table for a specific institution centre).I have created another bit of VBA code that creates a spreadsheet and loads the records from the query in to the spreadsheet.Each centre has a unique Sequence Number (Indent Number)At the moment though, all I can do is import one table (records for one institution) in to a spreadsheet. I want to end up with calling the function and having an output of 48 spreadsheets being saved to my desktop, each spreadsheet containing records of a different center.I have thought about putting a loop in, but not sure how I would quite go about it.
Here is my code to create the spreadsheet:
Public Sub ExcelExport(lngIndentNumber As Long, strFolder As String, strCrit As String, strReport As String)
', ctlLabel As Label,
DoCmd.SetWarnings False
[code]....
View 2 Replies
Apr 2, 2011
I'm Creating a wrapper dll for my favorite Windows API functions. Normally when windows API calls fail, Nothing happens and you don't know why and this frustrates me. Although you can use their return value to determine If it was successful.
[Code]...
View 6 Replies
Dec 6, 2010
What I am trying to do is have a class where the functions of the same name are both instance functions and shared functions.
Public Shared Function Get...(byval xx as xx)
and
Public Function Get...
The Public Function uses a Property xx created in the constructor, whereas the Shared Function has the parameters (byval xx as xx).
View 1 Replies
Feb 28, 2012
I am creating a gridview and need to gather the data from various functions that return a type of IEnumerable. I've created gridviews using a dataset as a datasource, but how does one use multiple data sources(of IEnumerable) to populate one gridview? Like how do you combine all that into one dataset?
View 1 Replies
Jun 14, 2011
some advise or links, where I can find, how to seperate Code and Design 100%?
View 5 Replies
Jun 2, 2010
I have 2 seperate web services. They both run on the same machine.One of the functions is the same between the 2 web services. It is a huge function and i hate having to repeat code. Is there any way to share the code between the 2 services other than having one service request the function from the other service? I'm a bit hesitant doing it that way because im worried about performance. It would mean for each request into service A i'd need to create a service B instance and call it.
View 5 Replies
Apr 4, 2010
I am currently working with an IPhone API which consist of about 40 pages of aspx along with their respective aspx.vb pages. They are all partial classes because the API continues to add other phone platforms to it. Currently I have them residing just in a folder. /API/0.1 and /API/1.0..How would I call the functions from those IPhone API classes without having to put them in the App_code? [code]How do i use that function in a webform? or do I need to put it in App_Code? [code]
View 1 Replies
May 18, 2010
I moved from SubSonic 2.x to 3.0 and noticed that all my classes are combined into the ActiveRecord.vb(cs) file. Is there a way to have my classes generated individually in a separate folder (DAL) as I was doing with 2.x?
View 2 Replies
Apr 13, 2009
visual studio 2010 - Altering array values in VB.NET
View 8 Replies
Nov 28, 2010
I am just starting out with a practice VB project which involves selling donuts and coffee. I have written out the code which the program works but the code is very messy. This program contains functions and radio buttons to calculate a subtotal, tax, and total due. There are four variety of donuts in Group Box 1 listed as: Glazed at .65 each, Sugar at .65 each, Chocolate at .85 each, and Filled at $1.00.
The coffee choices in Group Box 2 are listed as: None at 0.00, Regular at $1.85, and Capuchino at $2.50 each.I want the cashier to be able to select a radio button to choose between the donut choice in group box 1 and then choose one coffee choice in group box 2. A textbox calculates the subtotal, a textbox calculates a tax of 3%, and a textbox calculates the total due adding the subtotal and tax.
Everything works fine but Ias I said before it is quite messy which I keep making it worst.I need to write one function to calculate the donut, one function to calculate the coffee, and one function to calculate the sales tax. Then I need a sub procedure to clear the subtotal, sales tax, and total due amounts when a radio button is clicked.I have been working on this for the past month ,code I have so far:
Class frmMain
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()[code].....
View 4 Replies
May 18, 2012
how to write the this three function in c#:
Randomize, Int ,Ran()
Randomize();
// This is my VB Code
for ( ; (KeyOK(sKey) == false); )
[code]....
View 3 Replies
Sep 9, 2009
What is the best way to keep my source code separate to the output from compilation? I can change the "Build output path", but I am still getting files created in the "obj" directory whenever I compile. I want to have a directory tree that only contains source code.David Streeter
View 7 Replies
Apr 21, 2009
I am creating an IDE for a game script with similar functionality as the Visual Studio IDE (at least, some of it). The game script consist of code that looks visually a bit like C code. It uses braces to define the start and end of a 'class' and uses nested braces to define the start and end of an 'event' in a class.
What I want finally is to have two Comboboxes above the text editor, one that lists each Class and the other listing each Event. The comboboxes should also show the Class and Event that the caret is currently in, just like in Visual Studio.I have attached an example of such a script (you can open it with Notepad).However, here is a short example where you can also see how I "defined" classes and events:
class1
{
event1
{
[code]....
As you can see, the classes are the 'names' of each block of code, defined by matching braces { }. The events are the names of each nested block of code, also defined by matching braces { } but inside a class. There is only one level of nesting.As you can also see, the layout can follow the standard C-style layout, or a slightly different layout (using the opening brace on the same line as the class/event name), or even a completely chaotic mess. As long as the braces match correctly, the code is valid.So in short, the large blocks are classes, while the nested blocks are events.
What I want to do, is parse an entire script, and store all the Classes (and eventually, also all the Events, but let's forget about them for now). I want to store the Class name, start position (defined as the start index of the name), end position (defined as the index of the closing brace) and the full text (defined as the text between start and end position, so including the name).
vb.net
Public Class clsClass
Private _Name As String
[code]....
The code works basically by finding every first opening brace (the opening brace of each CLASS, not event), and then loops through the class (using a brace counter to keep track of the nested braces) until it found the last closing brace. It then stores the name, start, end and fulltext in a new clsClass and adds it to the list to return.
View 3 Replies
Oct 19, 2011
I'm trying to validate a form to be filled out by the users, and when the required section isn't filled, I increment an
ErrorCount += 1
variable to show that error(s) have occurred inside the program, I then also set an
ErrorArray()
to whatever the corresponding field number is, now I have 0-12 (13 fields). What I have also done is titled the labels that are associated with all of these fields to correspond with the ErrorArray() value that might be set, such as.
PatLabel0
PatLabel1 etc.
What I am trying to do is loop through the array contents, depending on which ErrorArray() values have been set, to go and set the corresponding fontcolor property of that label to red, to show that these now need to be filled out. This is what I have, but Visual Studio doesn't allow me to use the iteration through the loop as a reference to changing properties. Can anyone point me in the right direction to trying to figure this out, or at least tell me what else I could do. Just seems doing 20 if....then....else.... statements with 2 - 3 lines in each of them is redundant when 1 function line could do the same job. This is what I have.
for i = 0 to UBound(ErrorArray(12))
if(ErrorArray(i) = "*")then
PatLabel(i).forecolor = color.red
[code]....
that is basically all im looking for initially, but I can't do it.
View 1 Replies
Dec 10, 2008
have just started vb .net and im working with the 2005 edition, but i would now like to make a program that i can use at home that will alter files names,Bassically where i rip cd's to put them onto my mp3 player they are always given a name starting with 01. etc, what i would like is a small bit of code that uses a while or for loop to go through every file in the folder and remove the first three characters.
View 4 Replies
Mar 15, 2011
I got a DataGrid Control that uses an Adodb.Recordset as a data source. I'd like to change the data type of the dodb.Recordset.Fields at run time. PS:I tried use the Type property but I got a message that it can't perform the operation when the object is open. Then I tried closing it with Close() but then it says the field is not available.
View 4 Replies
Jun 15, 2009
I have an Active Directory browser written in vb.net 2008 that allows an end user to visually browse AD. Currently it displays the full DN for each child and what I want is to display just the name of the OU. Something tells me I would use the Tag() function but after playing with it, I just couldn't figure it out. All I removed was our internal domain name.
Would someone like to review what I have now and offer some ideas on what I would change to alter how the tree is viewed while retaining funuctionality?
Imports System
Imports System.Collections
Imports System.Collections.Generic
[Code].....
View 6 Replies
May 13, 2010
I have some xml that I read from an xml document, now I need to take that same xml and then change one field and then drop back to a file again. [Code] so then as you can see I tried to use a new open of the document from scratch and I get the same error. I read that its because I may have 2 imports that have the same method? I had 2 XML imports and made it only this, but still get the same error. [Code] how to fix my issue or a better way to read and change the one field I need to change?
View 3 Replies
Oct 23, 2011
I'm using the Chilkat add-on to read email from a pop3 server. I can download the headers fine but the headers all download into one column.How can I get my email to put the headers in the appropriate columns?
'Display the From email address and the subject.
ListView2.Items.Add(email.From)
ListView2.Refresh()
ListView2.Items.Add(email.EmailDate)
ListView2.Refresh()
[Code]...
What I am trying to do is to download the "From" person into the "From" columns and the "Date" of the email into the date column, so on and so forth but I'm not able to get them to go into their separate columns.
View 3 Replies
Jan 3, 2011
I'm using a 2D array to store data in a grid and all the data is ones and zeros. By default, the array is all zeros. When I attempt to modify values in the array using variable(y)(x) = 1 where x and y are integers in range it changes the value to 1 in the entire column, not just a single cell.
[Code]...
View 2 Replies