Use Array Literal In A Condition?
Aug 2, 2011I just learn how to create an array literal in VB.NET. [code]...
View 1 RepliesI just learn how to create an array literal in VB.NET. [code]...
View 1 RepliesIsn't there a way in VB to pass an array literal? Say the subroutine ask for an array of integers and you have just one. Can't you do something like
DoSomething({MyNum})
instead of
Dim MyNums as Integer() = {MyNum}
DoSomeThing(MyNums)
I'm thinking I'm just missing some adornment to the array literal inorder pass it.
I have two array I'm trying to compare at many levels. Both have the same structure with 3 "columns.The first column contains the polygon's ID, the second a area type, and the third, the percentage of each area type for a polygone.So, for many rows, it will compare, for example, ID : 1 Type : aaa % : 100..But for some elements, I have many rows for the same ID. For example, I'll have ID 2, Type aaa, 25% --- ID 2, type bbb, 25% --- ID 2, type ccc, 50%. And in the second array, I'll have ID 2, Type aaa, 25% --- ID 2, type bbb, 10% --- ID 2, type eee, 38% --- ID 2, type fff, 27%.So, my function has to compare these two array and send me an email if there are differences.(I wont show you the real code because there are 811 lines). The first "if" condition is [code]I have two different layers in a geospatial database. Both layers have the same structure. They are a "spatial join" of the land parcels (55 000), and the land use layer. The first layer is the current one, and the second layer is the next one we'll use after 2015.So I have, for each "land parcel" the percentage of each land use. So, for a "land parcel" (ID 7580-80-2532, I can have 50% of farming use (TYPE FAR-23), and 50% of residantial use (RES-112). In the first array, I'll have 2 rows with the same ID (7580-80-2532), but each one will have a different type (FAR-23, RES-112) and a different %.
In the second layer, the same the municipal zoning (land use) has changed. So the same "land parcel" will now be 40% of residential use (RES-112), 20% of commercial (COM-54) and 40% of a new farming use (FAR-33).So, I wanna know if there are some differences. Some land parcels will be exactly the same. Some parcels will keep the same land use, but not the same percentage of each. But for some land parcel, there will be more or less land use types with different percentage of each.I want this script to compare these two layers and send me an email when there are differences between these two layers for the same land parcel ID.The script is already working, but it takes too much time. The probleme is, I think, the script go through all array2 for each row in array 1. What I want is when there are more than 1 rows with the same ID in array1, take only this ID in both arrays.Maybe if I order them by IDs, I could write a condition. kind of "when you find what you're looking for, stop searching when you'll find a different value?
Is there any way to make an array structure a part of a condition?[code]...
View 9 RepliesI am going to be performing an XSLT transformation, transforming XML to an HTML table. It's tabular data, so that's why I'm not using div's.
[Code]...
using System;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
[code]....
I have the above code sniplet. I am trying to bind the anchor within the literal to a function in a following manner:
onserverclick = "Download"
But the event is not firing. The requirement is that anchor is rendered through literal only.
Possible Duplicate: Multiline strings in VB.NET
How do you specify a multiple line string literal in Visual Basic .NET?
You can do it in C#: Multiline String Literal in C#
How do you type binary literals in VB.NET?
&HFF // literal Hex -- OK
&b11111111 // literal Binary -- how do I do this?
I have a ListView called "orderReceiptTable" which I am able to properly access from the Code Behind. Within it is a literal called "orgName" which I obviously would like to populate with an organization's name. After much searching it was determined that FindControl was the right course of action. Perhaps I am using FindControl improperly but I am unable to actually have it "find" my Literal control. The code block is being called in the Page Load.
My code looks as such:
Dim orgNameString As String = getOrganizationName.getOrgName(organizationID).ToString()
Dim myOrgName As Literal = FindControl("orgName")
myOrgName = CType(orderReceiptTable.FindControl("orgName"), Literal)
If Not (myOrgName Is Nothing) Then
[Code] .....
If I needed to escape a double quote character within a string literal I'd use two consecutive double quotes as follows:
Dim name = "Chuck ""Iceman"" Liddell"
However, it doesn't seem like consecutive # works the same way. The compiler is expecting a compiler directive to follow the # character, even when its enclosed in double quotes. How can tell the compiler that I want a # character in my string?
EDIT: as a few of the answers below point out, # is not a reserved character. I closed my solution in Visual Studio and re-opened it and no longer got the compiler squiggles warning me.
I have the same problem as stated in this question, but the accepted solution there was a "works on my machine" answer.
[Code]...
And I receive the error: BC30201: Expression expected.
Does anyone have a more detailed idea of what could cause this?
In an older thread i was looking to read data into a temporary datatable, Now I think I have gotten this working, but i am not sure how to connect the temporary data set (if needed) to access the data from this.
Again here is my code
[code]...
I'm getting the error below when I try usign the XmlTextWriter in my VB aspx page
[Code]...
I'm trying to assign the literal text as a URL redirect as follows:
Dim l As Literal = CType(sender, Literal)
l.Text = "<a href =""~default.aspx?tabid=65&itemid=" + id + """>Results</a>".ToString
The problem I'm having is with the ~
Without the squigly (does it have a proper name?) I don't get the full proceeding part of the URL.
With the squigly it displays the URL perfectly but with the squigly still there.
[URL]
This might just be a matter of taste, but I'm wondering if there's a "recommended" way to compare a variable of type Object (which might be Nothing or have a different dynamic type than String) to a string literal in VB.NET. The following options obviously won't work:
If myObject = "Hello World" Then ... -- won't compile
If myObject Is "Hello World" Then ... -- tests for reference equality, which is just wrong
If myObject.Equals("Hello World") Then ... -- throws an exception if myObject is Nothing
If DirectCast(myObject, String) = "Hello World" Then ... -- throws an exception if myObject is not a string
Thus, the only (simple, single-expression) solution I could find is to use
If "Hello World".Equals(myObject) Then ...
which looks a bit clumsy to me. Did I miss any obvious alternative, other than doing type checks or explicit checks for Nothing?(Of course, we're talking about Option Strict On.)
With Option Strict On:
Dim theLetterA As Char = "A"
returns an error about converting the string "A" to a Char.
What is the syntax to enter a Char literal?
how to capture the 'ID' literals from the following xml file example using VS and VB 2010. I plan to assign it to a temp variable for later use.
<?xml version="1.0" encoding="utf-8"?>
<Rows>
<Row Sortorder="1">
[code]....
Public Class Form1
Private
[code].....
I'm programming in VB.NET using Visual Studio 2008. I need to define a string literal containing the character "÷" equivalent to Chr(247). I understand that internally VS uses UTF-16 encoding, but when the source file is written to disk it contains the single byte value F7 for this character.
This source file is processed by another program that uses UTF-8 encoding by default, so it fails to interpret this character correctly, attempting to combine it with the following single-byte character. What encoding would correctly interpret the single byte F7 as the single character ÷?
Alternatively, is there a way of expressing a non-ASCII literal that uses only ASCII characters - like using some kind of escape sequence?
I would like to add a variable data to a string literal WITHIN the HTML tag[code]....
View 1 RepliesHas anyone ever tied to get a reference to resolve and then concatenate with a literal in an app.config key? I am trying to point to a resource, which in this case is a PDF file, and want to make the path to the resource configurable.[code]What I get is a string with the embedded double quotes I want but the Application.StartupPath reference does not resolve.
View 1 RepliesI am coding a dynamic asp.net page in which i want to have text boxes in a page and the number of text boxes depend on a previous user input. Since the number of text boxes are decided dynamically, I am going with designing them in code rather than in the aspx page.Now I need these fields to be mandatory and so want to indicate a RED asterisk symbol in front of the label corresponding to each text box.I am really new to working in .net and I couldn't figure out how to set a specific color to a labelcontrol.[code]....
View 1 RepliesI want my User Control to be able to have Literal Content inside of it. For Example:
<fc:Text runat="server">Please enter your login information:</fc:Text>
Currently the code for my user control is:
<ParseChildren(True, "Content")> _
Partial Public Class ctrFormText
Inherits UserControl[code]..............
And when I put text inside this control (like above) i get this error: Parser Error Message: Literal content ('Please enter your login information to access CKMS:') is not allowed within a 'System.Collections.ArrayList'.This control could have other content than just the text, so making the Content property an attribute will not solve my problem.I found in some places that I need to implement a ControlBuilder Class, along with another class that implements IParserAccessor.Anyway I just want my default "Content" property to have all types of controls allowed in it, both literal and actual controls.
I'm creating <div>'s and appending them to a literal's text property. I have added a <a> element to the text so that the user can click on a specific element. How can I tie that to a function to handle the event in the codebehind (vb.net) ?
Example of my Literal.Text ...
For Each row As DataRow In oDataTable.Rows
MyLiteral.Text &= "<div style='font-size: 8.25px; text-transform:uppercase; padding:3px; background: #FF8C00; border: 1px solid #000; margin: 0 5px 0 5px; display:inline-block; float: left;'>" _
& row.Item("LastName") & " | <a href='#?"& row.Item("ID") & "' style='color: #000;' >X</a></div>"
Next
So the above code I want to somehow allow the user to click the X link and then it would remove that person.
I am trying to use xml documents to store data for a movie database, but am having an issue
here is the code I am using
Imports <"...movies.xml">
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
[Code]....
Why do I get that xmlns = "" in the movie parent node?
Of I remove the parent node from the movieAdd variable it puts xlmns = in all the nodes
I am trying to update an Oracle Database record and i keep getting this error:
ORA-01704: string literal too long 5
I looked up that error and it seems that i have a limit of 4000 charters since i am using Oracle 10g. However, the prgblem is that its the same exact data i am putting back into that record so that is why i am unsure as to why its giving me that error for the same amount of data i took out of it.
Here is my update code:
Dim myCommand As New OracleCommand()
Dim ra As Integer
Try
[code]....
how to show error msg in literal if no record found in database according to the text entered in textbox1 and textbox2 else if show record in gridview if the text entered in textbox1 and textbox2 will be found in database ...
View 1 RepliesWhat I need to do is create comboboxes populated with values from a CSV for each class object selected from an Active Directory schema.
So lets say twelve classes are selected, the next form will display the class names in a checkedlistbox and will require twelve comboboxes for associating AD classes to CSV fields. Since the number of AD classes selected will always vary, is there a practical way to code it so that the objects can be instantiated from values stored in a variable?
Other languages support macro substitution, where the variable's value is interpreted as a literal at runtime. Developing in Visual Studio 2005, VB version 8 .netFramework 2.0xxx
I have names of all labels in a table of an Access database (one field is a form name- it can be repeated, the second field is a label name - it must be unique for the same form, the third field is a text of this label). E.g. the first record has field1="Form1", field2="Label1", field3="Smith" My question: How can I refer to a label programmatically using the Access database? E.g. Form1.Label1.Text= "Smith" In C languge there was the opportunity "remove the quotation marks" from the text ("Label1") and get the literal (Label1). Is this opportunity in VB.NET?
View 10 RepliesMy app has text boxes to accept input from user to questions shown on labels. When the user input is valid, a literal is added to a string incorporating the user input. If the user doesn't input anything or if user inputs "no" or "None" I want the literal and the user input to not add to my string. Make any sense? See my code below:
[Code]...