Global Conditional Define (#const) Statements

Dec 7, 2010

Is there a way to define a conditional define, i.e. #const, in a asp/vb.net app that it accessible across multiple source files? I want to use, for example, #const useOracle=TRUE but to be able to change it's value in only one place.

View 1 Replies


ADVERTISEMENT

Can #Const Be A Global Variable?

Feb 6, 2010

VB2008: I would like to set a #Const value in a module and use it throughout my project. Is this possible? It appears that the #Const scope is limited to the function it's in.

View 5 Replies

Php - ASP.Net - Looping/conditional Statements In Layouts?

Sep 21, 2011

Coming from PHP and more specifically many of the MVC frameworks out their, I've been use to using basic foreach and if constructs in PHP directly in the layout. Now that I'm learning ASP.NET I'm presented with more proprietary concepts like a ListView to control looping, etc...

So to give an example of what I want to do..

<div id="container">
<h1 class="header">Title</h1>
<% For Each item In ItemsCollection %>

[Code].....

Then there isn't a lot I have to handle in the Code Behind file... besides making ItemsCollection available.

Is This considered Bad Practice? Should I spend the time learning the proprietary controls for ASP.NET? Are there specific limitations of this approach?

View 3 Replies

Validate User Input - Loop Conditional Statements To Indicate Errors?

Mar 20, 2011

I have several text boxes I need to validate. I am not understanding how to validate in Visual Basic 2008. So I deployed standard If Statements to handle bad data. I am having two problems.

Lets say the user entered wrong data, example, numbers; an error message is displayed. The text boxes cannot contain numbers, be left empty or contained characters, like !@#$. The problem is if the user enter text, and then entered a wrong data again the code does not work or display error message. How can I make the conditions so that they throw out error message even if the user had previously entered good data.

Another example: If the user enter good data in text box 1 and bad data in text box 2, the error message does not work.

Finally, how do I filter out characters to allow only text. Is there a way to use this code on multiple text boxes with out writing the entire code for each form control?

Here are the conditional statements.
Private Sub btnDataSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDataSubmit.Click
If IsNumeric(txtDataEntry.Text) Then
lblErrorDisplay.Text = "Invalid Name!"
lblErrorDisplay.BackColor = Color.Red
[Code] .....

View 12 Replies

How To Define Variable As Global

May 14, 2009

I have no idea as to how I can define a variable as "GLOBAL" in VB Express 2008. I used VB V 3.0 and if I remember correctly the statement "Global varName as Integer" allowed me to use the variable across different forms. I've tried the statement "Public varName as Integer = 0" on Form1 but Form2 tells me the variable is not declared.

The statement (in Form1) "Form2.Label1.Text = CStr(varName)" displays the value on Form2 in Label1 but I cannot then use the value again in Form2, e.g. "Label2.Text = Label1.Text". How I can transfer a variable value from one form to another and manipulate that variable in the second form?

View 4 Replies

Define Property (IsInEditMode) And Global Variable (isEditMode) In ASP.NET?

Mar 9, 2009

public partial class _Default : System.Web.UI.Page
{
private bool isEditMode = false;
protected void Button1_Click(object sender, EventArgs e)

[code]....

What is the VB code equivalent for the above C# code. Mainly how to define Property (IsInEditMode) and Global variable (isEditMode) in ASP.NET?

View 5 Replies

Define Some Global Variables Of A Class - Variables Occupy Memory?

Mar 23, 2012

I define some global variables of a class as follows:

Private Class MyClass
Private var1 as Decimal
Private list1 as List(Of string)[code].....

But I found that after this form is closed, all above variables, var1, list1, list2 still exist in memory. I thought they should be collected by gc since the form is already disposed as I confirmed.

Add: I have monitored half an hour after the form is closed. But these variables are not collected by gc. I have an automatic update procedure on the form which uses above variables.Since the above variables still hold values, the automatic update procedure is always called which causes exception. (One quick fix is to check if form.isDisposed in update procedure. But I do not think this is elegeant. Besides, these variables occupy memory.)

View 2 Replies

Program That Will Generate A Pattern Using Do While / If Else Statements / Do Until Statements

Oct 11, 2009

Can someone give me a site to a tutorial that will help me write a program that will generate a pattern using do while, if else statements,and do until statements. I have been using google but I can't find anything. I need to generate patterns a certain size 6 by 6 or similar such as something like a checkerboard but where the ^ symbols is there a suppose to be a blank space..

View 3 Replies

How To Use DEBUG Const In DLL

May 3, 2010

I want to know how to use DEBUG const in DLL.-> I have a web application in vb.net-> I have a DLL whith some function.Now i have reference this DLL into my web application. And now i want to check in dll whether my application is in DEBUG mode or in Realease mode.Second thing i want to check some validation in constructor based on that constructor will throw exception and i want to show it on page without handling. I have used try catch in constructor and not used in page, so it will give me error in dialog box not in page.

View 11 Replies

Changing The Object Declarations To Global Using The 'global' Keyword Evertime?

Mar 15, 2012

evrytime i add new controls to a form in vb.net the designer regenerates code and asks me to make corrections, so i have to keep on changing the object declarations to global using the 'global' keyword evertime it regenarates code,especialy dataset objects.how can i prevent this?

View 1 Replies

Cant Declare A Public Const ?

Apr 2, 2012

Is their a reason why I cant declare a Public Const this way?

HTML

Public Const whatever as string = my.application.settings.xxx.tostring

I don't understand why not.

View 4 Replies

Class Of Public Const?

Jan 13, 2011

I am making a program where there is a number of strings are needs and they need to be pre-defined. I rather not store it all in a XML file as I don't want anyone going in and altering them.

Has anyone ever created a class of public constants just to make cleaner code or is it considered bad practice?

View 5 Replies

Use Global X As String In Vb6 In A Module To Declare It With Global Privelages?

May 1, 2009

i could use Global x as string in vb6 in a module to declare it with global privelages, how can i do this in vb2008? how to declare a global variable in vb2008? so that i could use it anywhere i want. i know global variables are not recommended in programming but i need one.

View 4 Replies

Const Wm Visual Basic 2010?

Jun 27, 2011

druring my search how to display a picture from a webcan using vb I found in some treads the following code:

Const WM_CAP_START = &H400S
Const
WS_CHILD = &H40000000

[Code]...

View 2 Replies

Enumerate All The Const Values In A Class?

Jun 2, 2012

I have a class in vb.net, it looks like

public class myclass
Public Const AAA = 111
Public Const BBB = 222
Public Const CCC = 333
End Class

Now i want to get all the values (111,222,333) to an array list (or collection, or whatever) , how to do?

View 7 Replies

Expose A .NET Public Const To COM Interop?

May 18, 2010

For historical reasons, we need to expose string constants in .NET through COM interface.We managed to expose ENUM but we can't find a way to expose string const.We try the following code :

[Code]...

View 1 Replies

Error 2 'If', 'ElseIf', 'Else', 'End If', 'Const', Or 'Region' Expected?

Oct 28, 2009

I've made some function that generates an email template. Code it generates is pure HTML with CSS. Problem is compiler does this odd error and highlights each time '#' sign appears which is needed to define colors in CSS. I did try to change '#' to '/pound/' and then string.Replace() on RETURN but no luck. I'm more into C# so there i can escape special characters by using '' before them but something f$#$ed up there... Once i remove '#' all back to normal and compiles well.

View 2 Replies

If Statements Inside If Statements?

Mar 14, 2012

I am trying to figure out how to do this:

if (phrase = hello) then
"say hello"
if (phrase = how are you?) then

[CODE]...

So basically, I want it to work like a timeline. If I say hello, then it will respond and move onto the next if statement. Get it?

Here is the code I have now:

If phrase.Result.Text = "hello" Then

synth.Speak("Hello to you too")

If phrase.Result.Text.Contains("How are you") Then

[CODE]...

View 21 Replies

VS 2008 Dynamically Declaring A Constant - Public Const Blah As String = Variable & "something"

Aug 5, 2009

How would I go about dynamically declaring a constant? (It's value is dynamic, not the variable name)

View 5 Replies

Conditional Stylesheet Css?

Apr 29, 2012

The template I use for all of my pages looks at the style.css to get the header image. I want to change it so that it looks at who logs in and displays an image based on who they are.

View 3 Replies

.net - Perform An Assignment In An IF Conditional In .NET?

Mar 19, 2012

Is there a way to set a variable in VB.NET in an IF statement. I would like to do the following:

[Code]...

Is there some way I can get the last "ElseIf" to work? I know I can re-write it to get it to work but is there some syntax that will make it work the way it is?

View 3 Replies

.net Conditional Linq Query?

Sep 27, 2011

In this query against a datatable i'm trying to do some conditional filtering.The check against Timeband(index N) should only be done when the Index exists. (the base code only had three item fields, i've converted them to a simple list)

Dim res As DataTable =
(
From dr As DataRow In dtTimedRow.AsEnumerable()
Select dr

[code]....

The above code triggers an Exception if the count = 1. It executes the code next to imeBands.Count > 1 which it should not. What would be the correct solution for this code.In the mean time i've added a simple filter function.

View 1 Replies

Adding Conditional Search?

Oct 10, 2011

I am very new to VB and was thrown into the water with a very big project done in VB.What I am trying to do is this:1. The initial search is for locations within an area of 200 miles.2. If no locations are returned search for locations within 500 miles.Seems easy enough but I cannot seem to figure out how to do part two.If thunder.apps.ddr.franchiseconnect.bll.Current.Settings.Location.hasValue Then'we run this procedure to get the location's value from ZIP db for lat, long assignment

View 13 Replies

Asp.net - Conditional Javascript In .ascx?

Jul 13, 2010

I have a javascript src that i need to add to some of the pages in a site.

for example <script type="text/javascript" src="http:abcxyz.com/zzz"></script>

I want to add this conditionally on a .ascx page - if the Request.ServerVariables["SCRIPT_NAME"] ends with certain criteria.

The ascx language is vb, and there is no code behind.

View 2 Replies

C# - Conditional Image In Datagrid?

Jan 15, 2010

I have a datagrid in asp.net and vb.net, and i'd like to show the status of the item of a certain row with two possible icons.I have a function that checks validation and returns a boolean value that uses some fields of the datagrid.

View 2 Replies

Conditional Checking Of An Image?

Mar 28, 2011

imgTitle.Image = My.Resources.title
If imgTitle.Image Is My.Resources.title Then
MsgBox("Success")
Else

[code]....

View 1 Replies

Conditional Coloring Of Textboxes

Jul 24, 2009

I have some textboxes on a report in VB 2005. There are three "Status Types": A, B and C. I want an expression like this to work on a number of textboxes:

[Code]...

View 3 Replies

Conditional Combo Boxes?

Apr 14, 2010

I have two combo boxes: cboRepairCategory (plumbing, landscaping, etc) and cboVendors. I am using Stored Procedures in SQL to store the data from my database and then load them into the combo boxes.The cboRepairCategory will be loaded first. Once the user has selected what type of repair it is I want it to restrict the amount of vendors that can be selected, so instead of saying:CREATE PROCEDURE dbo.up_Fill_Vendor_Combo

AS
SELECT VendorID, CompanyName
FROM Vendors

[code].....

I would select only the vendors that have the RepairType of say Landscaping, so thecboVendor would load now only Vendors with Landscaping instead of all vendors.My question is this: Is this done in SQL in my Stored Procedure or is it done in VB in my functions for my combo boxes. I've never tried this before I am totally lost on it. I have fiddled with the code on both ends but to no avail.

View 2 Replies

Conditional Formatting Of Bound DGV?

Jun 20, 2009

I have a DGV that is bound to an Access DB DataTable. I have added a column in the DB that is either a 0 or a 1. When the program loads, I want to change the backcolor and forecolor of each row based on the value of this column's cell. ie: a 1 makes the row red, a 0 makes the row green. this column would be hidden in the DGV.

Is this possible to do at runtime even though it is bound?

I'm not sure when I would actually do the color swap, formLoad?

Second question, as I iterate through each row of the DataGridView and need to change the value of this column, will this update my DB automatically, or do I need to call an update() after each row?

View 7 Replies

Is There A Conditional Ternary Operator

Feb 23, 2009

In Perl (and other languages) a conditional ternary operator can be expressed like this:my $foo = $bar = $buz ? $cat : $dog;Is there a similar operator in VB.NET?

View 2 Replies







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