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


ADVERTISEMENT

Using Modules In .NET Considered?

Jun 7, 2011

During the design of a new application I was wondering if using a module with properties is considered to be a bad practice. Some example code:

Module modSettings
public property Setting1 as string
public property DatabaseObject as IDatabaseObject
End Module

The code above is just an example to emphasize my question. In the past, this structure was used a lot in VB6. In the past I used it as well in my .NET projects.

But nowadays with buzzwords like Dependency Injection, Testability and Separation of Concerns the above structure smells bad. I can't really describe why, but it just feels wrong. I must admit I'm not very familiar with the keywords above, yet.So I'm wondering whether the above code really is a bad practice. If so, what would you use a Module for?

View 4 Replies

What Would Be Considered A .NET Module In C#

Mar 16, 2011

VB.NET has classes and Modules, so my first question is what is the difference? Also, I noticed that C# does not have modules, but just classes, is there something in place of modules or were they removed for C#?

View 1 Replies

Is Backspace Considered Character

Oct 18, 2010

You need to test for the backspace character, and if it's there, fix up the input.Maybe something like this:

If Right$(TxtQP.Text, 1) = vbBs Then
TxtQP = Left$(TxtQP, len(TxtQP)-1)
End If

Or is the backspace not showing up in the string, but as the input character kicking off your procedure?

View 1 Replies

VB Is Using Structures Considered Good Or Bad?

Oct 10, 2010

I use to use Structures quite a lot in the VB6 days, and try to avoid them now with .NET. Just wondering if using structures in 2010 instead of a Class is considered nasty?

View 6 Replies

Which One Cannot Be Considered As A Counter Variable

Feb 15, 2012

which one cannot be considered as a counter variable?

counter = counter +1
counter = counter -1
counter = counter +3
counter = counter *2

View 10 Replies

VS 2010 - Timer Event Is Not Considered

Nov 18, 2011

Why after you pressed the button Button1, this application crashes without considering the event timer1??
Public Class Form1
Public timer_event As Boolean
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
timer_event = False
Timer1.Interval = 3000 '3 sec
[Code] .....

View 3 Replies

When Was Isnumeric Considered Legacy Code

Jan 3, 2012

When was isnumeric considered legacy code? I guess all that i have learned from my college class last semister is legacy.

View 4 Replies

VS 2008 - Are Arrays Considered A Type Of Collection Like Lists

Mar 2, 2010

Ever since I started using VB.Net I have been using the Generic List collection List(Of <Type>). Arrays, I haven't used so much. I used them a lot more when I wrote C code years ago.

1.) Are arrays considered a type of collection like Lists, Dictionary, Queue etc are? Or are they in their own category.

2.) Can I iterate over an array with a For Each loop like I can with other collections or do I stick with the normal For loop for arrays?

3.) There are certain methods that return arrays. Can I set a list object to hold this return value instead of an array?

View 6 Replies

Use The GoTo Statement In .Net?

Feb 19, 2009

I have process that needs to create a bunch of records in the database and roll everything back if anything goes wrong. What I want to do is this:

[Code]...

View 15 Replies

Creating A Goto Page?

Oct 20, 2009

Ive got my pdf file to open but i need to open the document on a specific page. button 4 is an accept button/ user clicks it searches and opens files.

im using VB2008 express my code is:

Dim readfile As String = ("C:Program FilesRimless Data SheetsApplication FilesRimless Data Sheets_1_0_0_4shape file pdfsShapes files")
Private

[Code]....

View 5 Replies

Goto A Specific Record On A Form?

May 16, 2011

I Have A form With With Data source DS1 Is There A Way To Filter The DS1 To Show A Specific Record Parameter Input Textbox

View 2 Replies

Listview Goto When User Types?

Jun 24, 2010

Is there a way to make a listview select an item based on what a user types? for example, If i have a listview with a column (last name), and the Listview is in focus, I want the user to be able to start typing and have the row select move to the row that has the letters in that column

View 4 Replies

Method To Return From A Goto Statement?

Oct 26, 2009

I just want to know whether there is any method to return from a goto statement.

[Code]...

View 6 Replies

Windows 7 Goto Standby Mode

Jul 7, 2010

I need to standby the remote computer(windows 7) in given time.

there are Server and clients... From server machine I need to standby(windows 7) the client system given time.

View 1 Replies

.net - Replicate Try/catch/finally Using On Error Goto

Jun 14, 2012

Suppose in VB.NET you have:

Try
Debug.Print("Trying...")
Catch ex as Exception
throw new Exception("Exception", ex)
Finally
Debug.Print("Finally...")
End Try

How would you write this using the "On Error Goto" construct? (please no questions asking why I would want to do this, just curious if it can be done).

View 2 Replies

VS 2008 - Goto Specific Part Of Code

Mar 21, 2010

I have a for each item in listbox:

try
'code goes here
catch ex as exception
end try
next

now, in my code, i also have if ex = certain error. i'd like it to go back to the top of the try. reason for not letting it do its thing is, i am wanting it to retry it, under the same item. So, is there a way to goto a portion of the code.

View 4 Replies

VS 2010 : Make Button Open Ie And Goto Url?

May 6, 2011

I need my program to open the users default web browser, and go to a specific url. Its actually a menustrip but still.

View 5 Replies

Listview String Value Goto Combo Box On Double Click

May 2, 2012

i have hard codeded combo like this suppose i select not tolerated by pattient this is listview box and i want "not tolerated by pattient" back to combo box on double click to list view box

View 3 Replies

Skip Empty Database Fields And Goto Next Step

Dec 4, 2009

How to tell the program that if the field is empty to skip it and go to the next step. I have tried IsEmpty (but it tells me the variable IsEmpty was not declared), I have tried to use different If statements but in most cases I get the message
"Conversion from type 'DBNull' to type 'String' is not valid."

I tried using an integer variable and setting it to
'Test = CStr(dt.Rows(I)("socSecNumber")).Length'.
It works for the first step (which makes sense b/c socSecNumber is never empty), but when I set the 2nd and 3rd ones
(TestFName = CStr(dt.Rows(I)("firstName")).Length TestLName = CStr(dt.Rows(I)("lastName")).Length If TestFName > 0 And TestLName > 0 Then...)

Then I am back to getting the message
'Conversion from type 'DBNull' to type 'String' is not valid'.
I do not know anything about recordset and when I did try to use it it displayed the message something like 'get and set are no longer allowed'.

The entire function is below:
Private Sub BtnCreateLetter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCreateLetter.Click
Dim SSN As String = TxtBxSSN.Text
Dim dt As New DataTable()
[Code] .....

Is it possible to include something in the SELECT from table? Such as:
"SELECT * FROM" & Students & "WHERE" * NOT DBNull
or
I do not know if it is possible to use variables in the SELECT from table code but if it is I thought perhaps could make a variable named FieldContents and pass it to a function that would do something like:
"SELECT * FROM" & Students & "WHERE" * FieldContents LIKE '[A-Z]'

View 8 Replies

Give A Good Example Of The GOTO Statement In Visual Basic 2008?

Jan 15, 2010

I wanted a good example of the GOTO statement, I really want to know how to imply the goto statement in my future projects.

View 7 Replies

Once The Timer Has Been Stopped And Started, Code Does Not Goto The Elseif Part (i.e. I=5)?

Jul 19, 2010

i was trying to make a free microsoft word plugin in vb.net. It automatically fills a web form. The main problem with the plugin is that it uses web browser control and once it has filled a form it will need to navigate another form. The form can only be filled once it has completely been loaded.so my approach is

1. navigate to first site when form loads

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://google.com")
End Sub

2. use an integer i and use if statements to check which form to fill :

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEv entArgs) Handles WebBrowser1.DocumentCompleted
If (i = 1) Then[code].....

3. this is the main step. you see when main form loads, i=1 so browser goes to google.com (first form), when form is completely loaded, itchecks for value of i. Since i=1, it fills google. After filling and continuing i=2 and browser goes to my personal account page. This means browser again loads the document. Now i=2, so it fills my personal detalis. Now the timer starts. Since i=3, browser navigates to second site and fills the details.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If (i = 3) Then
WebBrowser1.Navigate("http://blogger.com")[code]...

now the problem arises. The browser does not go to the third site. Once the timer has been stopped and started, the following code does not goto the elseif part (i.e. i=5) why is that so?

View 4 Replies

VS 2008 - Use GoTo - Microsoft Seem To Use It A Fair Bit In The Internal .NET Framework Code

Sep 28, 2009

I've seen a few people on here saying that you shouldnt use GoTo in VB.NET and to be honest I've tended to agree as I have never needed to use it and there is always another way of doing something without using it. However, I'm just wondering what is so bad about it? I actually noticed that Microsoft seem to use it a fair bit in the internal .NET framework code, which is what makes me wonder why people are so against it.

View 26 Replies

VS 2008 Listing - Make A Textbox Goto The Next Line Evrytime

Feb 5, 2010

i have a problem with trying to make a textbox goto the next line evrytime i add something. ive been trying for a while, and came up with the script

[Code]...

View 3 Replies

.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

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







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