.net - Best Practice On IF/ELSE Statement Order?

Aug 20, 2009

Which is a better practice? (I'm coding in .Net if that makes a difference)

IF condition = true THEN
...true action--even if rare...
ELSE

[code].....

View 10 Replies


ADVERTISEMENT

Making A Tetravex Solving Program In Order To Practice My Code Writing Skills?

Feb 8, 2010

Well, i was thinking of making a Tetravex solving program in order to practice my code writing skills (language will propably be Visual Basic) and I need help finding an algorithm for solving it. For those that don't know what tetravex is see this http:[url]... . The only algorithm I can come up with is the brute force way, place a tile randomly in one corner and try every possible tile next to it and continue the same process, if it reaches a dead end revert to a previous state and place a different tile.

View 4 Replies

Using An If Statement And Z Order?

Feb 22, 2009

[code]...

where and how do I implement the if statements and zorder statments for each form. If btncustomerservice_click = true then Form2.Zorder1 Form2.Show ElseIf btncustomerservice_click = false then form2.Zorder2 End If I believe I need these statements to avoid any other possible exception or error messages. These statements worked in vb6. How do I do this in vb 2008. Do I need to? What else can I do.

View 3 Replies

Linq Using Variables In Order By Statement?

May 18, 2012

Dim gg = From gs In AllData_TableList Order By gs.Biology Descending, gs.ChemistryDescending, gs.English Descending, gs.Frensh DescendingAll I need is to make this Statement order Dynamically like this

Dim Variable1 as string=Biology
Dim Variable2 as string=Chemistry
Dim Variable3 as string=English

[code].....

View 6 Replies

Is Try / Catch / Finally Required With Using Statement In Order To Handle Exceptions

Jan 31, 2012

I wonder how to use statement handles exceptions?Do I need to wrap the using statements with a Try/Cath/Finally clause in order to be sure that the SqlConnection object is closed and disposed even if the containing code throws an exception? [code]

View 3 Replies

Need To Change One Combo Box (of Many) To Order Items In Descending Order

Nov 1, 2009

I have a combo box bound to a datasource. I need to change one combo box (of many) to order the items in descending order.I'm guessing I could order the collection in the dataset, but that will mean all my combo boxes will be reordered?

View 2 Replies

Re Order Column Order In A Data Bound DataGridView?

Apr 17, 2010

I have a databound Datagridview. The DGV is bound to a datatable of a strongly typed DataSet created using the wizard. Is there any way to re order the columns before displaying them eg: the Columns are displayed in the DGV in this other Col4, Col6, Col3, Col1,Col5, Col2

But I want to it to show as Col1, Col2, col3, Col4, Col5, Col6?

I realise that the display order followed the Column order in the database table and by extension, the datatable. I have re-arranged the columns in the Database but the Datatable still retains the old order.

View 4 Replies

VS 2010 : Access ORDER BY To Get DESCENDING Order

Oct 8, 2011

This might not be so 'VB' as it is 'SQL using VB' I have an application with a built in MS Access DB. I have a table that has a column full of integers, I shoot the DB a SQL "order by 'column name' " string and it returns the table ordered by my column of integers.BUT it returns them like this, and I want them like this

0 6
1 5
2 4

[code]....

How do I get the OrderBY to do a descending list starting with the highest number?

View 2 Replies

VS 2010 Tab Index Order And Control Order

Aug 18, 2011

I'm working on the exercise page 73 (VB 2010 in 24 hours). It's basically a form with 2 text boxes, 2 text labels and a command button. It's really simple and uses this loop to cycle through the items, and tell me the name of them in a Messagebox

[Code]...

View 5 Replies

Best Practice For A Search SQL Query?

Jul 1, 2009

I have a SQL 2008 Express database, which have following tables: [code] Now I need SQL query to search for word (i.e. Beyonce Halo Music Video) against these tables.

-For Title exact phrase will get 0.5 points
-For Description exact phrase will get 0.4 points
-For tags exact phrase will get 0.3 points
-For title all words will get 0.2 points
-For description all words will get 0.2 points
-For title one or more words will get 0.1 points
-For description one or more words will get 0.1 points

And I will show these videos on basis of points. What will be the SQL Query for this? A LINQ query will be more better.

View 2 Replies

Best Practice For Location Of A Query

Feb 4, 2011

I'm writing in VB.net 4.0 and using SQLExpress 2008 R2. In a DataGridView, I would like to display (no edits) data coming from multiple tables in my database.A second Grid (different data, still multiple tables) will need to allow editing and saving of data.I understand creating a View in the database and using that as a source for the DataGridView.I also assume that there are ways to query and create a data source for the Grid totally within my VB program.Would someone explain the consequences and implications of the different approaches?

View 2 Replies

Best Practice For Saving Images

Apr 9, 2009

I am allowing users of the admin panel of my website to upload photos, its a simple process where I check the validity of the image and then save it to a folder, then I also have to record a couple of database records for that image to be able to retrieve it later, my saving function is as follows...The function that uploads and saves the picture in the folder with a name i construct in another function: [code] and the function that creates the database record for that same picture: [code] Now I know that what I am doing is full of best-practices violations, so please point me out to what I should do, keep in mind that the users might delete the pictures later, so I wanna make sure that I can delete the database and file of the picture, and the whole issue of the path.

View 2 Replies

Best Practice While Working With Dataset?

Jun 25, 2009

What is the best practice while working with dataset amd datatable.Actually I have seen that very few information is online when it comes to working with multiple base table.Suppose there is one master table and a details table. The need of MASTER table is suppose just one column (say ProductName), while the application mainly works with the DETAILS table.My idea, we use JOIN to create a single datatable and work with it. But am surprised how little information is available when it comes to working with Multiple Base Table and the limitation of SQLCOmmandBuilder in such situation.

View 15 Replies

Internet Connection Best Practice?

Dec 8, 2010

What is the best practice way of detecting internet connection?

From Windows Vista onwards, a status is set in windows that is displayed in the task bar. However, I cannot call this function/api/whatever, since some of the client pc's are still on xp, and only due for upgrade in 18 months.

so do i use and request something like [url]... to try and see it it works, and on the catch block set the return value to false, or is there another way?

Second part of this question, If no network connection is available, I can use [url]... to dial a connection. Will this use internet explorer's settings, or dial the connection marked as default in DUN?

Public Sub Life(ByVal AnyEvent As Object) Dim myNewLife As New Life Dim Happiness As New Collection Happiness.Add(AnyEvent) myNewLife.Experience(Happiness) End Sub

View 4 Replies

Set Variables To 'Nothing' Is A Good Practice?

Jan 27, 2011

If I got Dim myRect As Rectangle = New Rectangle(0,0,100,100)Is it necessary or just fine to later do this: myRect = Nothing Or it isn't necessary?IF it is necessary, are there other cases it isn't for my variables?

View 2 Replies

WCF Data Objects Best Practice

Mar 24, 2011

I am in the processing of migrating from web services to WCF, and rather than trying to make old code work in WCF, I am just going to rebuild the services. As a part of this process, I have not figured out the best design to provide easy to consume services and also support future changes.

[Code]....

View 1 Replies

VS 2008 ORDER BY That Does Not Order Correctly?

Jan 14, 2010

I have to order a table following a logical order but I cannot find the appropriate ORDER BY clause.To simplify I have 2 fields field1 and field2

1 record : field1 contains �2� and field2 contains �1�
2 record : field1 contains �1� and field2 contains �2�
3 record : field1 contains �2� and field2 contains �2�

[code].....

View 16 Replies

Best Practice Example Of An MVP Implementation Of Unit Testing

May 4, 2009

Can anyone point me towards a complete scenario using MSTest,vb.net, with or without mocks,MVP (supervising controller)

View 1 Replies

Best Practice For Sharing Variables Across Forms?

Mar 27, 2011

I need to share variables across two forms in vb.net. One of them is the main form and the other is a child form.

Create a static/shared variable in one of the forms and access it in the other forms via:
Form1 frm = new Form1(); //creating object of parent to access shared variable
frm.a = "abc"; // passing value

Send an instance of the main form to the child form when creating the child form. The variables can then be accessed via a property function. Create global variables in a module. This seems like the easiest option, but I doubt it is the best option.I also read something about delegates and events, but I don't know how to implement this.

View 4 Replies

Is Using GoTo<label> ALWAYS Considered Bad Practice

Aug 23, 2011

I'm just wondering why using GoTo<label> is so frowned upon?I'm learning VB, and I want to develop good habits as I go. One thing I don't entirely understand, is why everyone avoids GoTo like its the plague (except in error handling...). I feel like GoTo could be useful in some situations.

View 1 Replies

Recommended Practice Is For Importing Namespaces?

Mar 27, 2012

Just wondering what the recommended practice is for importing namespaces. Are you always better importing the namespace like the fisrt snippet of code, or are you better to type the full namespace inline with your code.

I like both methods; the first is tidier and takes less code, the second can identify exactly where your accessing some logic from which can provide some clarity when looking over the code. Just wondering if there are pros/cons for either or if this is just a personal preference, currently I use a combination but would like to keep consistant.

[Code]...

View 2 Replies

VS 2005 - Best Practice For Comparing Strings

Jan 21, 2010

Below two which is the best practice to compare strings...
If "A".ToLower = "a" Then
'....
End If

If String.Compare("A", "A", True) = 0 Then
'...
End If

View 2 Replies

VS 2010 Best Practice To Clean Up An Object?

May 15, 2012

I've got a class that looks like this

[code...]
What is the best way to "clean up after myself" when I am done with this newFS object?

View 3 Replies

What Are Performance Consequences Of Questionable Practice

Aug 29, 2011

I come from a C# background so I'm not quite up to snuff on my VB just yet.I've run across this practice all over our code base and it is never used for chaining.I am wondering what performance consequences (if any) this might create. [code]

View 2 Replies

.net - Is It Bad Practice To Access A Data Member Directly

Jul 26, 2010

I recall being told by a professor the following is bad practice. But it makes stepping through code a lot less tedious. I'm just solicting comments on pros and cons:

Friend Class MyClass
Private isEmpty As Boolean
Public Property IsEmpty() As Boolean

[code]....

View 3 Replies

Best Practice - VB Projects - Using Such A Large Database With Many Tables

Feb 21, 2012

The Adventureworks database is used extensively for tutorials in Visual Basic applications. This has many tables that can be bound to a solution. What I would like to know is, when using such a large database with many tables and using lots of them, is it better to construct your program with a number of projects all under one solution or to put everything into a single project. If you use a number of projects, what is the syntax for accessing each module from a menu strip in your main form? I know how to do this in a single project - all you do is Form(x).show. In Adventureworks, you have a table for Employees that could be put into a single project with a number of forms - one for data entry, one for displaying all of the employees, a filter to a single employee, etc., etc.

If two small projects rely on each other for some reason, again the syntax for linking them could be an issue. Would it be better to combine them into a single project? My reason for asking is that I would feel safer if I created an application on a project by project basis and then brought them all together in one solution. This way they can be tested individually and then linked together where necessary. Making a disastrous mistake in one then only requires a small re-write rather than the headache caused by a total crash of the whole solution. I would like to know which option professional developers take. I am using Visual Studio 2008 Professional and SQL 2005 Express

View 5 Replies

Best Practice: Setting Up An EventLog For A Windows Service

Oct 9, 2009

What are best practices when creating a custom event log for a windows service? I've set my service on a timer so it fires up every day (except weekends) at the same time. For the last 3 days, I've been getting the following error: The source 'DMCS57ExportService' is not registered in log 'DMC S57 Export Log'. (It is registered in log 'DMCS57ExportLog'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property.Based on that error, I know there's something wrong with the code that creates the custom event log (see below)

[Code]...

View 3 Replies

C# - Best Practice For Complex Shared / Static Members

Sep 7, 2011

I took over an ASP.NET application and have found this throughout several classes in the application. The programmers before defined several shared/static variables that act as "complex enums" throughout the application. As a fairly new programmer, it doesn't look like best practice.

Here is an example:
Public Shared SecureCommentsWrite As New Task("Secure Comments Write")
Public Shared SecureCommentsRead As New Task("Secure Comments Read")
Public Shared EditEmergencyContact As New Task("Edit Emergency Contact")
Public Shared DisplayPersonalReferences As New Task("Display Personal References")
Public Shared EditPersonalReferences As New Task("Edit Personal References")

The constructor takes the description, then loads the ID key from the database using a stored procedure (the database is SQL Server.) This seems like a good idea since we deploy this application to multiple databases and want to ensure that we load the ID key that's in that database in case it changes. However, since there are literally hundreds of these in the application, the first load takes a while.

View 4 Replies

Creating Temp Local Variables - Bad Practice?

Jan 12, 2012

When I want to maintain code readability and keep things neat. I would create temp variables . Below is one of my functions that uses it. Is it a bad practice? I would create temp variables cost more memory ?

Private sub test(byref transac as transaction , byref txntime as string )
Dim cmd as OracleCommand = nothing
Dim Adapter As OracleDataAdapter = nothing
Dim SQLStr As New StringBuilder
[Code] .....

View 9 Replies

DB/Reporting - Best Practice For Jagged Data Storage

Jun 10, 2009

say you have a database that you want to store 100 different recipes in. Out of that 100 recipes 20 have 5 ingredients, 30 have 7 ingredients, 30 have 4 ingredients and 20 have 6 ingredients. So what's the best practice for storing an unknown number of items in a database?

Currently what I am doing in these situations is storing them in a single field in a database separated by a comma. Then when I have to retrieve them I split them by the comma into an array. This doesn't seem right to me but I haven't noticed an impact on speed or efficiency, so what would be the best practice to handle this situation?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved