Hash Table Versus Switch Statement?

Sep 8, 2009

I have about 100 strings that depend on an integer value. There is potential for the list to grow to 255. What is the faster/preferred method of assigning the string based on the passed integer, a hash table or a switch statement. I googled around and can't seem to find anything that compares the speed of the hash table lookup vs. the speed of the switch statement. Is there an easy way I could measure the speed myself or any links to articles describing the performace of each method?

View 4 Replies


ADVERTISEMENT

Anchor - If Statement Using The Value Of Hash In URL?

Feb 6, 2012

I have a page with a URL that includes a hash value (www.mysite.com/#123).What I want to do is use that value to determine what is displayed on the page - much like using a querystring.I am using the hash value because the content on the page can be changed client side (I am avoiding page reloads where possible) - if the user then links to another page and uses the back button to return, I need to use the hash value to display the page as it was when they left it.So I'm looking for an if statement that will look something like this:

[code]...

View 1 Replies

C# Switch Statement More Limited Than .net 'case'?

May 4, 2011

I was reading an interesting article here and it made an interesting point about the 'case' statement in vb.net vs the 'switch' statement in C#, which I've pasted below:The following Visual Basic Select Case statement can't be represented in C# with a single switch statement:

Dim Condition As Integer = 55
Select Case Condition
Case 1, 3 To 5, 10, 12, 14, Is > 50

[code]....

I've always found the switch statement in C#, with dropthrough and consequentrequirements for a break in each case, to be a bit unwieldy. Is there any reason they haven't enhanced the switch command to allow these situations? W

EDIT AFTER CLOSE: I'm surprised this was closed, really. With the number of extension methods and helper classes I've found online for other things, I thought an enhanced 'case' would be a good chance. I somewhat hoped a luminary such as Jon Skeet may have commented on the background reasoning, rather than the individuals below who've obviously thought 'religious debate' as soon as more than one language is mentioned.

View 3 Replies

Select Case Versus If Statement?

Oct 20, 2009

I am not really a fan of if statements. I think they should only be used when comparing different values like this:

Dim status as boolean = false
Dim number as integer = 5
if status.equals(true) then

[Code]....

or msgbox on a different line whatever you want.... What is this rule about that select case should only be used if there more then 2-3 options. Is it wrong to use a select case instead?

View 23 Replies

.net - Switch/Select Statement Jump To A Different Case Clause?

Oct 18, 2011

Say I have this in VB.NET:

Dim executeB As Boolean
Select Case myVariable
Case "a"
'some code
Case "b"
'some code
Case Else
End Select

If myVariable is "a", control will go into the first case statement. Now let's say if myVariable = "a", but inside a's case block, I find that executeB is true, is it then possible to jump to the second case?

View 5 Replies

Creating A Class That Can Be Compared To A String In A Switch Statement?

Jan 13, 2012

Is it possible to create a class in VB.NET that can be compared to a string in a switch statement? For example, let's say I have a class Foo:

Public Class Foo
Public Bar As String = "test"
End Class

Is it possible to implement some interface or override some equality operator so that I could use Foo like so?

Dim foo As New Foo()
Select Case "test"
Case foo
' It worked!
End Select

View 2 Replies

Switch Statement Select Case On An Object's Type

Aug 19, 2009

[code]How would I switch on an object's type but using VB.NET's Select Case?I'm aware that some might suggest using polymorphism but I'm using a hierarchy of small message classes so that really wouldn't work in my csae.

View 6 Replies

.net - Reason For Sorting A Hash Table?

May 29, 2009

I was asked by an employer to sort a hash table. I always thought that the usage of a hash table was in a way non-sort friendly. Am I wrong in thinking this, and if not can you point me to a good VB.Net(Yes Kill me now, but it's an old system) method of sorting a hash table.

View 3 Replies

VS 2005 Add Data To A Hash Table?

Mar 19, 2009

Currently I add data to a hash table, then later on I loop through the hash table. To my horror I discovered that when you use FOR EACH with a hash table it doesn't return the items in the order you added them.I'm looking for a collection that I can add, edit and delete items from and loop through from start to end in that order.

View 28 Replies

C# - Split String To Hash Table Using LINQ

Jan 23, 2012

I have:
string s = "A=1,B=2,C=3";
I need the output in hashtable using LINQ. Hashtable should be filled as
["A"] | 1
["B"] | 2
["C"] | 3

View 2 Replies

Create A Hash Table Using A Multiplication Method?

May 17, 2012

i need to create a hash table using a multiplication method and i need to create an array of linked listso how i can to create array of linkedlist in vb or c# ?

View 1 Replies

Hash Password And Save Into Database Table?

Jan 14, 2012

I have a register.aspx and a login function and i am using vb.net

in my register.aspx...i have a user name textbox and a password text and a submit button. IF the user click on the submit button, the password will be hash and store with the username in the database table called "Customer"

1st Qn: i have a problem is that i never try before hashing, so i not sure how to code it , hopefully if someone got a sample or example to teach me it will be nice

2nd Qn: besides that, in my login function, how am i going to compare the hash value for password that is store in database with the password in the textbox to allow to login?

View 2 Replies

VB 2010 - Array Versus Data Table?

Mar 22, 2011

I am interested in the pros and cons of data tables and arrays in VB 2010. I programmed decades ago in FORTRAN and used arrays extensively.However, I frequently see data tables in code snippets and don't know when they should be used in lieu of an array.

View 4 Replies

[2005] Today.date Versus Now Versus DateTime.Now?

Jan 16, 2009

just want to know what is the difference between these date values?Once some one told me that its difference is server date and client date but not sure which one he meant.Below is 3 type of date currently I'm using and don't know what is the difference between them.

DateTime.Now is from System.DateTime.Now
Now is from Microsoft.VisualBasic.DateAndTime
Today.date is also from System.DateTime

View 4 Replies

Check An If Statement In A Table Or Database?

Jan 1, 2011

Is it possible to check to see if the text in a textbox is present in a table/database and then display the corresponding data.

View 2 Replies

Using A Case Statement With An Int Entry From A Table?

Apr 15, 2011

What is the best way to compare an Int entry from a table in a case statement?Using SQL server 2008 R2, Visual Basic Express with LINQ to SQL.The code I tried doesnt work:

Private Sub UpdateSetOpt()
Dim db = New ACEDataContext
Dim SRM = From q In db.Settings

[code]....

View 2 Replies

Add 2 Table When Using The INSERT Statement In Query Builder?

Feb 13, 2012

It seems like the query builder in vb only allow 1 table to use the INSERT statement, so are there any way add more than 1?

View 2 Replies

Check Insert Statement Of Dataset Table?

Mar 5, 2010

my program is "live" and my customer has troubles because it doesn't functioning as well as it should.I don't know what happen, did I changed something or not but suddenly data won't save to database from newly created forms. Beside this form I have additional 20 forms and everything is working like a charm and I use same code logic to save data to database. I tried to find myself what could be the reason, check by entering data directly to database table (works fine), check insert statement of dataset table (seems fine, too) and everything I could imagine. But now I ran out of ideas and I had to ask here.

Also, I added 3 fields to database table (nvarchar, int and decimal). All 3 of them allow nulls. I changed dataset and data entry form and now data won't insert if I dont enter values to int and decimal fields. Also, this decimal field doesn't accept 0 value if enter but if I assign value 0 from the code than it is ok. I'm not sure if I somehow changed concurrency and somewhere. I tried to find where I can change it but I couldn't find it. I use Visual Studio 2008 and Sql Server 2005 Express. Language vb.net.

View 1 Replies

Created An Sql Statement From A Table That Will Out Put 18 Rows Of Data

May 7, 2009

I am trying to input specific information on a form.I have created an sql statement from a table that will out put 18 rows of data.I have opened a recordset and instituted a do until loop.I need for the program to look at each row and if the Standard Score = the value of a field I have on the form it takes the value of the other three columns in updates it on the form.I have created the code and it works for upto 3 (Do Until loops)records, but when I try to add a 4th in the SQL statement and put in another do loop my computer runs it but it acts as if it freezes up. [code]

View 3 Replies

Creating Table - Getting Insert Statement Error?

Feb 23, 2010

I am trying to insert into a DB with has the following columns:
ID (autonumber), BonderIdentifier (text), Username (text), Login (date), Logout (date).
BonderIdentifier, Username, Login is the PK.

Here is what I do:
Public Function submitNewToDB(ByVal sessionData As BonderSession) As Boolean
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim str As String
[Code] .....

Like I said I get an insert into error and I dont know why. Nothing is in the DB yet and the table is created. I ran the built string in Access as such:
Insert into Session ([BonderIdentifier], [Username], [Login]) values ('Mork', 'sean', '2/23/2010 11:12:42 AM')
And it works.... but in VS it doesn't.

View 4 Replies

Execute A SQL Statement And Put The Result In To A Data Table?

Aug 16, 2010

I want to execute an SQL statement and put the result in to a data table.

Sub getvehicletypes()
Dim dt As New DataTable
Dim intLine As Integer = 0

[Code].....

Once Ive got it in a dataset I need to work out how to search the dataset for a code and return the corresponding description and vice versa

View 10 Replies

For Each Statement To Find Data Table Records?

Apr 12, 2010

I have a database application with several data tables. How can I use a for each statement to add the records of the datatable into a collection?

View 7 Replies

Get Data From The Event Table And Use The SQL Query Statement?

Aug 31, 2011

I have three tables set up in a MySQL database called "event", "status" and "user". (as shown below:

EVENT TABLE (below)
STATUS TABLE (below)
USER TABLE (below)

and when I get data from the event table I use the SQL query statement below to bind the persons first and last names together as one variable called "name" and then bind that name to the respective user_id; and so on. However when I make changes to the event table it doesn't show the changes I've made. I'm certain it has something to do with the way I'm retrieving the data.

SELECT CONCAT(u.lastname, ', ', u.firstname) AS Name
, s.message AS Message
, DATE_FORMAT(e.timestamp,'%b %d %Y - %r') AS DateTime[code].....

View 2 Replies

Run A SQL Statement To UPDATE A Column In A Table With New Data?

Apr 27, 2012

Attempting to run an SQL statement to UPDATE a column in a table with new data. The column being updated is defined as varchar(40) and the new data is 41 bytes (varchar(41)). I get a generic 'data will be truncated' error message, but no detail on which column caused the problem. I've attached a sample VB program to illustrate the issue. In this scenario, Company is defined as varchar(40).

My question: Can I get a more detailed error message? i.e. can I get an error message that tells me the row and column that the truncation occurs in? Often times, I may be updating hundreds or thousands of rows and only one value in one column from the source file is too large for a database cell. As a related question, does each OLEDB provider create its own error messages. i.e. will the MS SQL Server OLEDB provider potentially give different text in the error message than say the MS Jet OLEDB provider?

Imports System.Data.OleDb
Module Module1
Dim cn As OleDbConnection

[Code]......

View 3 Replies

Syntax Error In ALTER TABLE Statement?

Nov 25, 2010

cmd = New OleDbCommand("ALTER TABLE " & ComboBox1.Text & " ADD COLUMN " & TextBox1.Text & " TEXT", cn)

Syntax error in ALTER TABLE statement.

View 3 Replies

VS 2008 - Taking Information From SQL Two Table Statement

Jun 11, 2009

I got a table related to another table by orderref. I need to know what should be my SQL adapter command if I need to take some information from one table and some from another where orderref = "" or should I be making two separate SQLs?

I used to have this when I had only one table:
myStr = "select * from orders where Orderref='" + txtorderref.Text + "'"
Dim sqldaHistory As New SqlDataAdapter(myStr, nwindconn)
sqldaHistory.Fill(myDataset, "orders")

View 2 Replies

Add Number Field In To FoxPro Table By VB 6 Program And SQL Statement

Feb 17, 2009

i am using vb/vb.net and the database is visual foxpro 6.0 then i want to create the tables from the application using sql statement.i need to add the number field into the table. i can not add the number field in the tableres.open "CREATE TABLE Customer ( CustName char(50), CustId int(2))",conXavier

View 2 Replies

Asp.net - Create A LINQ Statement Where The Table Name (FROM) And Column Name Is Variable?

May 11, 2012

In my programming task I've gone down a dark alley and wished I hadn't, but there is no turning back now.

I'm building up a SQL statement where the table name, column name and id value are retrieved from query string parameters i.e. ("SELECT [{0}] FROM [{1}] WHERE [Id] = {2};", c, t, id)

But it isn't as bad as it looks, I'm protected: Only authenticated users (i.e. signed in users) can execute the Page_Load I'm checking that both the table and the column exists beforehand (using GetSchema etc.)I'm checking that the Id is an integer beforehand All my tables have Id columns The database connection is reasonably secure

[Code]...

View 1 Replies

Creating A Condition - IF Statement Which Is Checking Each Row In The Data Table

May 4, 2011

I have a IF statement which is checking each row in the data table (for a match) and ELSE statement with commands which are executed if the If statement is not satisfied. Now I would like to write like so that it goes to the Else part BUT ONLY for values which are not satisfied in the IF statement. If I am more specific; I would like to calculate values if a match is found and just print them if it is not fond (usually there are both cases). Now the problem is the bold text; if there is a match found I don't want it processed BUT if the match is found I do. How can I write that?

currencyPosition = 0
Dim d As Integer = w + 100
For Each currency In Ary

[CODE]..........................

View 2 Replies

Use The Combo Box Value As A Table Name In Access Database Query Statement?

May 1, 2012

[Code]...

how can get the name of the table that = to the name of the combobox1 when i select it.

[Code]...

View 6 Replies







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