Declaring A String In C#?

Jun 18, 2010

In the middle of attaching a Google Custom Search Engine onto my page,I have a string which I would declare in C# as

String rxPattern = "<(?>"[^"]"|'[^']'|[^'">])*>";

How do I convert it to a string in VB?I mean store the same value into the string variable rxPattern using VB/VB.NET?

View 1 Replies


ADVERTISEMENT

Declaring A String Variable?

Mar 29, 2012

if this silly but I am trying to declare a string variable by the following line

[Code]...

View 2 Replies

Declaring New String At Top Of Class?

Nov 23, 2009

I had a problem with CLR profiler. But it worked eventually and the results were outstanding. My app took 47 milliseconds to run before and after some adjustments CLR profiler runs in 6 miliseconds! This had to do with String values in a resource file which apparently takes a lot of time. So this got me thinking, isn't it more effective if you would declare 1 String at the top of your class and constantly change it throughout your code? Instead of creating a new String in a method when you need it.

Instead of using:
Dim text = "blalblalba"
You would do this everytime you needed a string:
text = "blalbla"

My question is... What exactly happens when you say text = ""? Does .net create a new String? It looks like you replace the text but what happens in the background? Would it be faster then declaring a new string?

View 3 Replies

Declaring String And Condition

Jan 17, 2012

I have a String variable in this page named "a".I wanted the scenario to be.When the page is started "a" will be null.But when the user selected an entry from the DetailView Control "a" will become "have".The following is my code. But i keep getting "a" = null even though i have selected an entry from the detailView control.[code]

View 2 Replies

Use StringBuilder When Declaring A String?

Nov 20, 2009

do you also have to use StringBuilder when declaring a String like this?:

View 11 Replies

Declaring & Initializing String Array?

Mar 10, 2011

I'm trying to return an array of strings from a function, and got surprised by an error.

I would have expected this to work, but it produces an error:

Public Function TestError() As String()
Return {"foo", "bar"}
End Function

[Code]....

I guess I'm unclear on the meaning of the {}'s - is there a way to implicitly return a string array without explicitly creating & initializing it?

View 3 Replies

Late Binding - Declaring A String Variable And Assigning The Item Property?

Nov 27, 2011

I have a problem involving late binding, and I absolutely cannot for the life of me figure out how to fix it. I have spent hours researching the problem to no avail, so I am turning to stackoverflow as a last resort.The problem is pretty much this: I am creating a grocery list application. I have a class named Item which stores the name, price, quantity, and description of an item on the grocery list. I have a module named ListCollection which defines a Collection of Item objects. I have created an Edit form which will automatically display the currently selected ListCollection item properties, but whenever I attempt to fill the text boxes, it tells me that Option Strict disallows late binding. I COULD take the easy route and disable Option Strict, but I'd prefer to figure out what the problem is so I know for future reference.I shall paste pertinent code here. (Late binding error is in EditItem.vb)

[code]...

I have tried declaring a String variable and assigning the Item property to that, and I have also tried grabbing the value directly from the List item (not using the Get function), and neither of these made a difference.

View 1 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

C# - Declaring Hex Constant In .net?

Apr 20, 2012

How can I convert the following code into VB.Net?

private const UInt32 temp = 0xE6359A60;

I tried the following but it doesn't work.

Public Const temp As System.UInt32 = 0xE6359A60

View 2 Replies

Declaring A Graphic In VB?

Apr 13, 2010

We have a great book written for Visual Basic 2005 that we type code that is prepared in advance. We are using Visual Basic Express 2008 and normally this works really great; type the code run the program and it works, however I am running into a snag.

The textbook shows the following code: IN THE(General) (Declarations)AREA we are told to type the following:

' Create a Graphic object to use with the game's bitmap
Dim myGraphicObject As Graphics = Me.CreateGraphics
' Create an empty Bitmap Object

[Code].....

is there a difference between VB 2005 and VB 2008 that would be causing the errors? or am I missing something subtle maybe mistyped?

View 3 Replies

Declaring A New Class Within A Sub?

Feb 22, 2011

Ok, basically i have 3 different classes: one is a NormalUser, one is a SuperUser, and one is an Administrator. I have on one of my form loads an if statement like this:

If frmLogin.lstCurrentUserData(frmLogin.lstCurrentUserData.Count - 1).Contains("Normal") Then
Dim player As New NormalUser

[Code]....

So based on an item in a list, i want to create a new instance of that class to be my player. now i know that code doesn't work, because the variable is only present within the if statement. my question is, how can i declare "player" as a new instance of the correct type, and still be able to access it in other subs?

View 10 Replies

Declaring An Array In .net?

Apr 7, 2010

I have 12 checkboxes jan, feb, ..... dec i want to display the checked checkboxes into a file i know how to write in the file but the format of displaying checkboxes is as follows if i checked jan, feb,march and april then output is jan,feb,march,april here my problem is how to collect checked value in array , and how to put comma betweem them.

View 7 Replies

Declaring Constants From DLL

Jan 8, 2009

How would you declare constants from a .dll, so you can use it in your program.

View 2 Replies

Declaring Each And Every Variable

Apr 26, 2011

Trying to declare some arrays. I haven't worked with them that I remember. I always took the long road, of declaring each and every variable, but would like to learn this method. The problem is I'm having trouble with the methods I'm finding on the net..[code]for some reason there is a squiggly under each MonsterName except in the declaration that says "declaration expected"

View 16 Replies

Declaring Pi As A Constant?

Apr 12, 2011

visual basic 2008 express

' the following lines declare the variables and constants
Dim intDiameter As Integer
Const dblPI As Double = 3.14159
Const dblAREA As Double = 140125
Dim intLabel As Integer

Private Sub PizaSliceCalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]...

I made a working program to calculate piza slices, i was told i needed to declare pi and the areas as constants. when i rewrote the program it no longer works. the result keeps coming back as 0.

View 8 Replies

Declaring Property In ASP.NET 4.0

Sep 2, 2009

I haven't check yet all the new features of ASP.NET 4.0 but I'm wondering if one of those features (VB syntax) is declaration of class properties oppose to C# in less code.[code]

View 4 Replies

Declaring The Use Of .Net 4controls?

Mar 2, 2012

I've got a problem in the display of controls on a form. The form controls are fine on my development system, but when installed on another machine, (same operating system, but evidently some other installed objects), the textbox controls in some of the forms have a black backcolor. Some of the tabs are pure white with the blacked out textboxes, some are the normal color. Some of the textboxes in the other sections are fine, some are not.

Is there any way that I can declare that all my controls are to be the 'standard' .NET Framework 4 variety?

View 6 Replies

Declaring Variables On .NET?

Jul 26, 2010

I actually came from VB6 and starting to learn VB.NET. I saw this line of code which I cannot understand how it works nor how it goes.

Private MAX_VALUE As Integer = (1 << 14)

View 2 Replies

Dll Calling / Declaring And Other

Dec 7, 2009

I am now facing the part II confusion with dll files. I would wanna load a custom built unmanaged dll that someone completely built, and load it within Visual Basic. I cannot reference it, because it doesn't seem to work. I wanna figure out how to use coding to load those dll's. Here is what I mean. If you have heard of irctunes. I can control itunes the way I want mostly using a dll. Here is the link to download the whole zip: URL] There is irctunes.dll which is unmanaged. I would wanna load it with Visual Basic. I cannot reference. There is an html file. It tells you the functions and parameters. I wanna access the functions that are within the dll file.

[Code]...

View 10 Replies

.net - Declaring A Byte Variable?

May 30, 2012

We can declare a byte variable like this, for hex '88'

Dim bytes = New Byte() { &H88 } My case, 88 is assigned to a variable, hexvalue

How to declare the byte with the variable hex value?

Dim bytes = New Byte() { &H & hexvalue }the above throws syntax error.

View 2 Replies

.net - Declaring A Variable As Byte

Feb 19, 2011

I'm trying out a program which I found on the net. Why is it necessary to put to curly braces at the end of the statement? It gives an error: "Byte has no constructors". Dim data As Byte() = New Byte(1023) {} I can't put the code like this either, it produces the error "byte cannot be a 1-dimensional array".

[Code]...

View 2 Replies

Declaring A Directory Path?

Apr 12, 2011

I've been testing the code below (vb 2010) and everything works except for the fact that I cannot get the statement "Dim dirName As String = Path.GetDirectoryName(Application.ExecutablePath)" to work. The dialog is "Path is not declared.it may be inaccessible due to protection level".As you may note I have it commented out below and went with the more explicit statement. Note that the code is from another author and I'd like to understand how to make this work as originally provided.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileName As String = "flatfile.txt"
'Dim dirName As String = Path.GetDirectoryName(Application.ExecutablePath)[code].....

View 4 Replies

Declaring A New Crystal Report

Apr 21, 2009

I have an application that I need to declare a new reportdocument. I try to do the following statement: report = new auditReport and it tells me that the auditReport is not defined. Even though I added the report to the project. I tried to do it in another application and it works fine.What could be wrong with the application that doesn't find the report I added to it?

View 1 Replies

Declaring A Variable For Form And Using It?

Feb 8, 2010

I have declared this variable in a module : Public GenericForm As System.Windows.Forms.Form

and then through code I can asign to that variable a specific form .For example GenericForm = Form1. Then I can use that variable to handle that specific form , for example :

GenericForm.Show

My problem begins when I want to handle a control on that form , for example :

GenericForm.TextBox1.Text = "aaa"

This code creates an error reading :TextBox1 is not a member of System.Windows.Forms.Form.I have been using code like this in VB6 and was quite useful ,but now in VB .NET I cannot .You see I have many forms on which there are some text boxes with the same name,so I declare a generic variable as Form and accordingly insert the code the desired text box conform the form I wish each time . Can I do this in VB .NET too ?

View 23 Replies

Declaring And Integer As Two Values

Jan 13, 2011

I'm working on a simple BlackJack (player vs dealer) system, that I plan on making gradually more advanced. However, while everything works brilliant, I'm yet to find a logical solution to declaring an Ace as both 1 and 11.So my question is, how do I pull this off. Below is the "New Game" logic (code) so it should give you an idea of what I'm working with (note how player scores are added together, I'm sure it's easy enough to understand...).I'd like lblPlayersum to still be a usable integer, though I'll rework everything if noone has a logical solution.Just quickly note that the "Cards" array is purely used to coordinate images."CardsVal" coordinates that values within the deck. Arrays 48, 49, 50 and 51 are the aces. (Currently defaulted to 11).[code]

View 1 Replies

Declaring Any Variables At All In A .Net Form?

Oct 6, 2011

I have just been experimenting with nesting classes within a User class I had already created.

E.g.

Friend Class User
[Number of Properties...]
Friend Class Address

[code]....

I get the same error message!!! "Declaration expected". Also I notice the variable's name is not coming up in intellisense. I have not come across this before as declaring an using variables and objects has been straight forward up until now.

View 2 Replies

Declaring Constant On VB 2010?

Feb 11, 2012

Having problem declaring constant on Visual Basic. rents is $200 per hour and is charge by minutes this is what I have so far.

const TOTAL_CHARGE_GROUP as Interger = 200 ©

View 8 Replies

Declaring Global Variables In Vb?

Sep 29, 2011

The user clicks a button, a new form is generated where the user enters his/her password? How can I keep an in-memory copy of the username?

For instance in web forms, I can just use Session ("User"). How can I replicate this with winforms?

View 3 Replies

Declaring Graphics Areas?

Jul 8, 2011

I have a form that I want to draw an image on.I also want this to be an animation so I can't use picturebox.However when I declare the graphics it gives me the error: "Type 'System.Drawing.Graphics' has no constructors"

:I have already import 'system.drawing:
Dim g As New Graphics() 'I get the error here
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

[code].....

View 7 Replies

Declaring The Public Variables?

Sep 23, 2011

I've created a 30 point wizard. Every step gathers between 1 and 3 variables. I've created a module and publicly declared the variables there. At the end of the wizard, one master form opens, gets all the variables, and displays them on one form. At this point calculations are run too which populates more variables. This works fine for one instance of the process.

the user may want to be running two instances of the wizard at once. Obviously, if the previous wizard is part complete and they start a new one, the variables are going to get crossed or replaced by the new wizard.Is there a way for the variables to be declared publicly but used in multiple instances?

View 8 Replies







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