IntelliSense In Xml Literals
Sep 2, 2009is there a way to enable IntelliSense for XML literals in VB9 (VS 2008)?The ideal source of IntelliSense is an XSD document, but I can use anything else format to do it.
View 2 Repliesis there a way to enable IntelliSense for XML literals in VB9 (VS 2008)?The ideal source of IntelliSense is an XSD document, but I can use anything else format to do it.
View 2 RepliesI have a class called Profile that has some simple properties and then it can have a collection of ProfileItem that again has some simple properties and then it can have a collection of ProfileItem (RECURSION). Now I am trying to generated a very simple save function using XML Literals that come with VB.NET (3.5).
[Code]....
Is it possible to use variables like <%=person.LastName %> in XML string this way?
XElement letters = new XElement("Letters");
XElement xperson = XElement.Parse("<Table><Row><Cell><Text>
<Segment>Dear <%=person.Title%> <%=person.FirstName%> <%=person.LastName%>,
[Code]....
If it's possible, it would be a lifesaver since I can't use XElement and XAttribute to add the nodes manually. We have multiple templates and they frequently change (edit on the fly).
If this is not doable, can you think of another way so that I can use templates for the XML?
[URL]
How do I use character literals in VB?I get error for following code:
op as Char
op = '+'
[code].....
I am using XML Literals and Linq to XML to read/write data to an external system.[code]The client now wants to put the url in a parameter table so the table can change to point to a test server or a real server. I assume that I cannot put a variable in my Imports statement.So how to I access the correct URL from a variable?url...
View 13 RepliesI'm using the following function to brighten up color values (it's a lambda in my code, but that shouldn't make a differende):
Function ReduceDistanceTo255(ByVal i As Byte) As Byte
Return i + (255 - i) 2
End Function
It won't compile, since the compiler interprets 255 and 2 as integers rather than bytes, making the result of type Integer. Unfortunately, there is no Byte type character, so I cannot just write 255B or something like that.There are a few obvious workarounds to the problem:
Function ReduceDistanceTo255(ByVal i As Byte) As Byte
Return i + (CByte(255) - i) CByte(2)
End Function
and
Function ReduceDistanceTo255(ByVal i As Byte) As Byte
Return CByte(i + (255 - i) 2)
End Function
[code]....
The first one is just plain ugly and hard to read, because every literal needs to be CByted. The second one performs calculations in integers and then converts the result to Byte, which is OK, but not as elegant as a pure-Byte operation. The third workaround doesn't require CBytes, but it's drawbacks are obvious.
In VB.NET I can easily embed strings into XML literals using <xml><%= "my string" %></xml>. How can I embed an XElement instance? I know I can use methods on the XElement, XNode, etc classes, but I'd like to do it in the XML literals if possible.
View 2 RepliesI am constructing some XML using XML literals. I have a function which returns an XElement.
Function RootElementFormattingFunction() as XElement
Return <Root Data="foo"/>
End Function
In reality it is a bit more complicated than that, but it is called from several places. Now I have linq sequence which generates a set of nodes which I want to make children of the XElement returns
[Code]...
I'm trying to use the builtin XML literals feature to create/read xml files using my own schemas, but I don't see a way to cast an abstract XElement from a base type to a more derived type.The schema/xml below shows in general what I'm working with, but using XML literals only allows me to use the base type in the IDE, so the xml below is treated as a collection of elements of the base type, instead one of the base type and one of the derived type.
<schema targetNamespace="Test" xmlns="Test">
<xs:complexType name="Base" abstract="true">
<xs:attribute name="Id" type="xs:int">
[code]....
Is there any other way of removing a specific tag other than looping through every tag and checking a certain value? I would assume this could become of timely process if there are many tags.
[Code]...
As basic as this is, it took me a few minutes to figure out, so wanted to share with the rest of the community to avoid anyone else from wasting their time.
I am attempting to generate the following XML string using VB.NET XML Literals
<Books>
<Book Name="The First Book" />
<Book Name="The Second Book" />
</Books>
[Code]....
But the compiler is complaining about the quotes that are supposed to surround the attribute value. I tried using single quotes, two double quotes, nothing works.
My problem is that I want to include control structures in the embedded XML. Specifically, I want to include or exclude an entire element (not just its contents) based on a boolean expression. The question extends to other control structures as well though.
I'd expect the <% %> syntax to support inling of code but that doesn't seem to function in VB.net's implementation (as opposed to the <%= %> for inlining the result of an evaluated expression, which does).
Here's some very simple code by way of example only.
Public Class Foo
Private bar As String = Nothing
Private baz As String = Nothing
[code]....
I'd much prefer to use the format of getXMLBad() if possible. In this short example it doesn't seem critical, but in much larger examples, the inlining of the logic is more readable and maintainable than the "assembly" style in getXML(). This especially true when the logic is in the middle of large block of static XML and when coding to a very strict or complex schemas.I'd be interested in the capability to extend this to Looping constructs as well.
Currently am working on a project that requires me to create some XML for use with a graphing plugin. I'm using XML literals and LINQ to SQL as follows
Dim x As XElement = _
<chart caption='Aantal aanvragen' xAxisName='Dag' yAxisName='Aantal'>
<%= From d In dailies Select _
[code].....
Dim task As XElement = <task>
<body>body</body>
<optional><%= myVar %></optional>
[code].....
I have a masked textbox on my form for a phone number. I want to store its value in my Database without the literals as the database field for that phone is only 10 characters long. How do I store this value in the database field without any literals.
View 3 Repliesbeen working on a large scale project and Iow looking into the document print engine for the application. been a while since Ie built an app that retrieves data from the database and outputs to Word. I generally always used the mail merge feature of Word but after reading the link above this seems far easier.
View 2 RepliesI have an XElement that I need to create via dynamic xml literals/embedded expressions and I need it to inherit the default namespace. This doesn't appear possible though through everything I've tried. how to make this work?
For example
Imports <xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
Sub CreateXAML()
Dim obj = "Rectangle"
[Code]....
I'm experimenting with xml literals in vb.net and there's something I don't get. Here's a small sample that illustrates the problem. I'm adding two PropertyGroup nodes to an empty Visual Studio project. The first one is added as xml literal, the second as new XElement:
Imports <xmlns="[URL]">
Module MyModule
Sub Main()
Dim vbproj = <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="[URL]">
[Code] .....
This code writes the following output:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="[URL]">
<PropertyGroup xmlns="[URL]"></PropertyGroup>
<PropertyGroup />
</Project>
As you can see, the first PropertyGroup node contains a redundant xmlns declaration. Why is that, and can it be avoided?
How can I get the variable My.Application.Info.Version.ToString to populate in the comments section?[code]..
View 2 RepliesIf I have a text stored in db, file, resource does not matter:
<code><%= Integer.MaxValue %></code>
Is there a way to do this: Dim el As XElement = XElement.Parse({variable containing text above}) and to have it evaluate the expression Integer.MaxValue?
What 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
In a nutshell, I am selecting values from a checked box column in a grid view. After checking the boxes I have a function that concatenates each customer number into a string called @CusList to use a parameter for a stored procedure Public Function SelectCusList()
Dim CusShow As String
Dim CusStr As String
Dim CusList As String
CusStr = ""
[Code]...
I find myself frequently turning off Intellisense because it adds wrong choices to my code. For example if I try to type "i " (without the quotes) it causes "int " to be put into my code. If I type "for " it may put "form " into my text.
Reaching for the ESC key constantly slows down my typing. (It's such a long way to reach for small hands). Is there an alternative way to exit out of intellisense without the highlighted choice being placed into my code, or is a way I can define a different key for this purpose?
I do not get intellisense working when creating a Property. How do I get intellisense to work here? Intellisense seems to work otherwise, just not with the Get / Set instantiations.
View 9 RepliesI am primarily a C# developer; however, I am currently working on a project for a client who preferred VB.net. I have managed to switch over fairly well, with one frustrating exception. When editing a C# file in Visual Studio pressing enter will select an item out of the IntelliSense window and keep the cursor at the end of the selected statement.
However, when editing a VB file, pressing enter selects the item out the IntelliSense popup AND moves the cursor to the next line. I realize that this is a small thing, but it drives me crazy, because it makes it really hard to switch between C# and VB projects.
I have searched for everything I can think of in Google and found nothing. Does anyone know of a way to change the IntelliSense selection behavior?
Using lambda's in VB.Net results in no intellisense. Is this a bug with VS2010 or expected? Note that it works fine in C#
Return Array.TrueForAll(chequeColl, Function(x) x.Number <> "N") 'No intellisense Number does not appear
Return Array.TrueForAll(chequeColl, Function(x As MyClass) x.Number <> "N") 'Now casted intellisense appears
UPDATE: Here's an example
Public Class Cheque
Public Property Id As String
Public Property Status As Byte
[code]....
In VB.NET projects, errors are highlighted immediately after cursor leaves the line. In C#, I have to wait several seconds for IntelliSense to highlight it. Also, the C# version doesn't show all project errors in "Errors List", unless you start to build it. Actually, it seems to work differently in every way. Is it possible to adjust that behavior?
I am using both Visual Studio 2008 and Visual Studio 2010.
I'm using coderush with vs 2008. coding in VB.net. I don't see any evidence of Intellassist, all i see is the usual VS intellisense. Is this normal? Preferred? Do most people leave the defaults or do most/some turn off vs's intellisense? Does intellassist somehow argument intellisence?
View 1 Repliesi know someone will say this belongs in database programming but i don't think this problem is to do with databases and is more to do with visual studio.
when i start to type oledb.oledb..... intellisense would usually give me an option for oledbcommandbuilder. in the current program i am doing for coursework this option is not given. i can choose oledb.oledbcommand but i do not know how to use it (too advanced for A-levels, yes i'm british) if i actually type oledb.oledbcommandbuilder visual studio does'nt show an error in my error list. so what is going on? how can i get visual studio to recognise oledb.oledbcommandbuilder?
Is it possible to enable XML intellisense in a C# class as it is in the VB editor? Similar to this article's prescriptions:
[URL]
Would like to not have to use xsd.exe to generate a class from the XML.