Way To Prevent Code Repetition

May 2, 2008

I have a button that when you click executes a certain code, lets say I make a menu that when clicked on should execute the same code, so how can I do this without having to copy/paste the same code twice.

View 10 Replies


ADVERTISEMENT

.net - Code Prevent SQL Injection?

Nov 25, 2009

I've been contracted to analyze an existing Data Provider and I know the following code is faulty; but in order to point out how bad it is, I need to prove that it's susceptible to SQL injection.

Question What "Key" parameter could break the PrepareString function and allow me to execute a DROP statement?

[Code]...

View 7 Replies

Asp.net - Prevent Firing The Code-behind Event From JavaScript?

Jul 22, 2011

I would like this ASP button control to stop calling its event handler when the JavaScript client method IsCorrectPrice() returns false.

<asp:Button ID="btnsubmit" runat="server"
Text="Submit" OnClientClick="javascript:IsCorrectPrice()"/>
btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnsubmit.Click

View 2 Replies

C# - Prevent HTML Encoding Of Attributes In The Code Behind?

Jul 27, 2011

I have the following in my aspx.

[Code]...

How can I get the < > " characters to render properly?

View 4 Replies

Code / Query That Will Prevent Duplication Of Data

Jun 5, 2011

i'm working on a voting system but im having problems in adding records... i have two a primary key, the idnumber and the address. the address is where I base if that certain address already voted. but the problem is everytime i try to add a record with the same address (ex. Block 1 lot 4), the data is duplicated which is not output i want. the program should detect that there is already an existing address.

[Code]...

View 3 Replies

Code That Prevent User To Given Number Less Than 8 In The Text Box?

Sep 11, 2011

what is code that prevent user to given number less than 8 in the text box. If the user give less then 8 number then message box box will appear which show Minimum Number is 8. Here is my code

Private Sub btnregister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnregister.Click
If TELEPHONETextBox.Text.Trim.Length = 0 Then
MsgBox("Please Enter Phone Number", MsgBoxStyle.Question)
Me.TELEPHONETextBox.Focus()

[code].....

View 2 Replies

Any Way For A Class To Prevent Outside Code From Declaring Variables Of Its Type?

Jan 6, 2011

Is it possible for a class of exposing a type for function returns, without allowing users of that class to create variables of that type? A couple usage scenarios:A Fluent interface on a large class; a statement like "foo=bar.WithX(5).WithY(9).WithZ(19);" would be inefficient if it had to create three new instances of the class, but could be much more efficient if the WithX could create one instance, and the other statements could simply use it.A class may wish to support a statement like "foo[19].x = 9;" even when foo itself isn't an array, and does not hold the data in class instances that can be exposed to the public; one way to do that is to have foo[19] return a struct which holds a reference to 'foo' and the value '19', and has a member property 'x' which could call "foo.SetXValue(19, 9);" Such a struct could have a conversion operator to convert itself to the "apparent" type of foo[19].In both of these scenarios, storing the value returned by a method or property into a variable and then using it more than once would cause strange behavior. It would be desirable if the designer of the class exposing such methods or properties could ensure that callers wouldn't be able to use them more than once. Is there any practical way to accomplish that?In formulating a question, it's difficult sometimes to draw the line between complicated usage cases, and simpler usage cases which aren't quite so important. Here's another usage case, and one closer to the one I'd be most interested in (though I'm also interested in Fluent chaining; being able to have something behave like a C++ reference to a value type would be nice, but probably too much work to bother with).I have a type which is somewhat like the Windows registry, in that it is a hierarchical collection of items, each of which may have a string value, an integer value, and/or a nested collection of items. I wish to be able to support the following types of usage:[code]As for the Fluent interface, my thought would be to have the WithXXX properties return a new instance of a derived class which shadows (not overrides!) the WithXXX properties with versions that simply modify the current instance. The return object from WithXXX would be known to be of the derived class, and would thus use the shadowed WithXXX methods, but once it was assigned to a variable, it would be regarded as an instance of the base class, so the next WithXXX would create a new instance.

C++ a stronger concept of value types than C# or vb.net, including the very useful concept of references to value types; it ensures that references to value types cannot be persisted outside the scope of the type in question. Unsafe code in C# can use pointers to value types, but they don't have the protections offered by C++ references.

View 3 Replies

Prevent Data Layer Refactoring Of ODP.NET Code And Transactions?

Aug 27, 2009

I am using Oracle 11g client, with ODP.NET. I am trying to add conditional Transaction handling.

Dim ds As New DataSet()
Dim txn As OracleTransaction
Dim _beginTransaction as Bolean = true
Using conn As New OracleConnection(ConnString)

[Code]...

How do I fix txn being nothing / null? The error is: Variable 'txn' is used before it has been assigned a value. A null reference exception could result at runtime. Edit: to RichardOD for pointing out that you can not explicitly declare that a transaction cannot be opend up on stored procedures via ODP.NET. I have verified that this is an issue. BUT We still haven't figured out why the error is occuring. I understand that txn is initially given a value w/in an if statement, but being defined outside of the try/catch block should make that irrelevant.... right? Or is that bad coding?

View 3 Replies

Disabling Button Before Executing VB Code To Prevent Duplicate Records?

Feb 15, 2012

I need to disable a button after its pressed so the user does not have the ability to click it again as this would replicate the process in some cases.After alot of searching I found some tips - alot of code I found I could not understand.This is what I have come up with:

On page load:
If Me.Page.IsPostBack Then
'lblDetails.Text = "disabled"

[code]....

I also read somewhere that I should use: System.Threading.Thread.Sleep(1000) to delay the process or something - not entirely sure why I would do this though.Although, the problem with my above code is that when the code behind page performs validation checks, it exits sub before executing my INSERT SQL code - so when it does this it also disables the button.I am not entirely sure if the above method is fool proof or whether it is a **** piece of code that won't work 100% of the time.On another website I found a script to put on the actual HTML page with <script> tags:

Code:
<script type="text/javascript">
disableSubmit(frm) {

[code].....

View 17 Replies

Lock / Prevent The User From Opening The Perl File / Code

Dec 15, 2011

i want to create an exe in vb.net by packaging few perl files along with it. when i am packaging those files i am able to hide those files by making the hide option true. but if the 'show hidden files' is selected those files will be visible. I want to lock/prevent the user from opening the perl file/code. want to know if there is any way to do it.

View 1 Replies

Get All Combination Without Repetition?

Jan 2, 2012

I have this code:

Dim combinations As New List(Of String)
Dim word As String = "abc"
For c1 = 0 To word.Length - 1

[code].....

View 2 Replies

Get Combinations With Repetition?

May 26, 2011

How can I write all possible combinations to the console? For example, if user enters abc, then it will write aaa, aab, aac, abb, abc, acc, bbb, bbc, ccc.

Here's some code:

Dim abc() As String = {"a", "b", "c"} '
Sub Main()
Console.WriteLine("Enter the amount of characters")

[Code]....

View 3 Replies

Interface And Graphics :: Disabling Button Before Executing VB Code To Prevent Duplicate Records?

Aug 5, 2008

I need to disable a button after its pressed so the user does not have the ability to click it again as this would replicate the process in some cases. After alot of searching I found some tips - alot of code I found I could not understand.This is what I have come up with:

[code]...

I also read somewhere that I should use: System.Threading.Thread.Sleep(1000) to delay the process or something - not entirely sure why I would do this though.Although, the problem with my above code is that when the code behind page performs validation checks, it exits sub before executing my INSERT SQL code - so when it does this it also disables the button.I am not entirely sure if the above method is fool proof or whether it is a **** piece of code that won't work 100% of the time.On another website I found a script to put on the actual HTML page with <script> tags:

[code]...

But although this works, it does not execute my VB code in the code behind page so I am a little confused where to go here.

View 1 Replies

Little Script/.NET Code That Will Prevent Auto-logout In Windows 2003 Server Edition?

Apr 3, 2011

I have a Windows 2003 server that we regularly RDP in to monitor some programs that we set up to run on the machine automatically.However, the server will automatically log me out after a few minutes of inactivity. Unfortunately the server admin (who has the admin rights to the server, which I don't) is reluctant to remove such restrictions "for security reasons".

Therefore, instead of me trying to fill up 10000 piece of paper getting a security exemption, I am just wondering if there is any tiny program that I can run on the server (either a script or some VB.NET code) that will trick the server into thinking I am constantly typing something even though I am not (For example, as if I am moving my mouse cursor once every 30 seconds or type any letter then erase it in notepad)?Note that since I do not have admin rights, any installation is certainly out of question, and the script, if any, can not require admin rights to run properly.

View 1 Replies

Add Items In Combo Box But Without Repetition?

Jun 2, 2011

the code for adding items in the combo box but without duplicates. i have an assignment which is a simple web browser. the combo box will be the address bar. and everytime i input an address, it will be added in combo box and should not repeat just like in the browsers

View 3 Replies

Remove Repetition From If-else Statement?

Jun 2, 2011

I have written an if...else statement which uses an array myArr and a string myStr as follows:

If myArr.Length > 0 AndAlso myArr(0) = "-1" Then
'Do stuff 1
ElseIf myStr= "xyz" Then
'Do stuff 2
ElseIf myArr.Length > 0 Then

[Code]...

It works exactly as I need. But It looks really confusing, mostly because the array length is checked twice. There must be a clearer way to write it, but I can't think of one. the order that each statement is executed is crucial. i.e. Stuff 1 has priority over stuff 2, which has priority over stuff 3.

View 6 Replies

VS 2008 Key Repetition Speed

Nov 20, 2009

Say you press and hold down a letter on your keyboard. The first letter gets added, there is a delay and then it repeats quickly on screen. Is it possible to skip this delay and go straight to the repeating part? I realize this might not be a visual basic question as much as a windows question, but if there is some way of toggleing it through my program, or using a workaround, i would like to hear the alternatives ^^ Setting the windows setting to fastest still has a small delay and others users would still experience it on other computers.

View 1 Replies

DB/Reporting :: How To Remove Repetition From List Box

Apr 1, 2008

Got a form linked to a database and i have the first column of data appearing in a list box on my form. In the database there are two records with the same value and so, of course, in my list box the value is given twice.How do i remove this repetition from the list box? (still keeping it the same in the database)

View 5 Replies

Multiplication Table With Repetition Structure

May 3, 2011

Here is the problem: In this question, you create an application that displays a multiplication table similar to the following figure, where x is a number entered by the user and y is the result of multiplying x by the numbers 1 through 9. Multiplication Table

[Code]....

View 2 Replies

Stop Execution In Repetition Structure?

May 11, 2012

I need to stop the execution of a program in VB.net. Within a repeating structure the program checks whether a variable is true or false. When the variable is false I need to stop the program execution. I do not want to close the program but simply stop it. One way I found was raising an exception, but I would not want to display the error message to the user. What is the best way to do it ?

Do
If myvariable=false then
throw new exception... 'Silent exception
end if
Loop until ....

View 3 Replies

Update The Listbox Without Repetition Of The Same Item?

Aug 27, 2011

i have a listbox which can be updated. and another listbox with some denominations concerning the first listbox. i am populating the listbox directly from the database. each item in the first listbox have many denominations given in the second listbox. the problem is when i add new items into the database, the items of the first listbox repeats. so in ma updated listbox, the items get repeated. how can i avoid this repetition.

[Code]...

View 2 Replies

[2008] Randomize Numbers Without Repetition?

Jan 20, 2009

The goal is simple... generate a set of random numbers with a certain range (e.g., 1-6, 5-10) with no repeats. I tried using a system with arrays where everytime a number has been generated, its marked as "used" and then the program is required to generate a new number. But it doesn't work!

Public randomnumgen As New System.Random
Public randomnum As Integer
Public iCounter As Integer
Public GotIt(7) As Boolean

[code]....

View 5 Replies

Asp.net - .Net Regex Match Grouping And Repetition Question?

May 27, 2009

I have the following VB.Net 2.0 in an ASP.Net app:

output = Regex.Replace(output, "<p>(?:(?:<!--.*?-->)|&(?:nbsp|#0*160|x0*A0);|<brs*/?>|[su00A0]+)*</p>", String.Empty, RegexOptions.Compiled Or RegexOptions.CultureInvariant Or RegexOptions.IgnoreCase Or RegexOptions.Singleline)

Example stuff it matches well:

<p></p>
<p> </p>
<p><br/><br/></p>
<p><!-- comment --><!-- comment --></p>

[code]....

View 3 Replies

Event Addhandler, RemoveHandler Repetition Conundrum?

Apr 14, 2010

I'm getting a bit more fluent in VB.Net, but am still a bit green around the edges in certain aspects. I'm creating custom controls, and am starting to rely heavily on AddHandlers to manage them.Until recently, I didn't realize that you can add multiple event handlers for the same control and same address

[code]...

The above code would create 10,000 copies of the same event, and if I would click on combobutton1, the event would fire 10,000 times. I only need to fire the event once, but sometimes my code is a bit circular, and there may be an instance where two or more addhandlers are designated for a given control and address. Is there a way to have a loop on my custom dispose event where it would look something like:

[code]...

Or better yet, remove all events from a control(On a side note, is there any way in the debug mode to see all the active events attached to a control?)

View 2 Replies

Validate Input Only Allow Each Number To Be Entered In Once (no Repetition)

Feb 25, 2009

how to validate 4 textboxes so that only numbers 1 to 4 can be entered but no number can be repeated.i already have code but it only validates some of the boxes and allows numbers to be repeated in other

Public Class frmGrid
Private Grid() As Short
Private Const intDimension As Short = 3

[Code]....

View 1 Replies

Repetition For List Of Settings With Unique Variable Names

Aug 12, 2011

this website seems great and this is my first post. Sorry if this has already been answered but I have been searching for a long time. I have a program with a list view in details mode. I have it load column settings (visibility, display index, width, etc.) when the form is opened and save them when closed. There are many columns...about ten so far...like folder, file, size, etc. Is there a way to access variable names from the values of other variables?

[Code]...

View 3 Replies

Print Click On The Quantity Of Copies Informed Skirt With Sequential Numbers Without Repetition?

May 24, 2010

What is missing is a way that when I give a print click on the quantity of copies informed skirt with sequential numbers without repetition

[Code]...

View 1 Replies

Prevent "Private X As New Y" Code?

Nov 27, 2009

I prefer object attributes to only be allowed to be initialised within methods, and that all attributes should be required to be initialised in the Constructor, even if they are initialised to Nothing, i.e. they still must be explicitly assigned a value during object construction.[code]...

View 2 Replies

How To Prevent Others Using Dll

Aug 16, 2010

Does anybody know how I can prevent others from referencing and using my VB.NET dlls?Because when I create a dll then I can easily reference it to my project and use the code in it. So my main concern is that when I distribute my application others can use these dlls.

View 8 Replies

Doesn't Prevent Pop Up

May 6, 2009

i coded a simple webbrowser and started surfing with it but i realise it doesnt prevent pop up advertisements.. how i prevent it?

View 1 Replies







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