OpenLLM-France/wikimedia huggingface dataset:
# Visual Basic .NET/Classes
## Introduction

The Class concept is the main foundation of Object Oriented Programming. In a world of Graphical User Interfaces and more complex programs, classes have become a very important part of programming.
To create a class, in the Solutions explorer, after a right click on the application, Add, then Class. Or select "Add Class..." from the Project menu of the menu bar.

## Terminology

object: A unit that has its own properties and methods for a user to use at his or her discretion.
encapsulation: Lets the user of the class control the data and operations of a class that can be seen from other classes.
property: Represents a data value associated with an instance.
method: An operation that can be performed by the class.
constructor: The method that is called when an object of the class has been instantiated.
field: A variable at the class level.

## Fields

Fields are variables that are inside a class but not inside functions, sub routines and properties. These variables are also not allowed to be called outside a class. Declaring these variables is simple, as shown in this segment of a class:
The class can call these variables up easily with "Me" calling. Look at this segment of a class to understand how:
Trying to call up a private field outside of a class will not work.

## Constructors

When a new object of a class is declared, we can initialize the fields of a class. For example, look at this segment of a class:
Technically, a constructor with no parameters is called an Empty Constructor or a Default Constructor. A Constructor that has parameters is called a Custom Constructor.

## Properties

Properties are divided into two categories: getters and setters. A getter returns a value from a class, much like how a function works and a setter sets a value into the class.
Because this class property is "Public", we can access it from outside the class. If it was "Private", it would be the complete opposite.

## Methods

Methods are pretty much sub routines specific to a class. These can be called up as many or as little times as the programmer desires.

## Instantiation

We use the keyword "New":

## Example Class

This is just an example of a class using all the above techniques:
# Visual Basic .NET/DataGridView
## DataGridView

To change the cell formatting based on content, handle the CellFormatting event. Other methods (e.g. setting the RowDefaultCellStyle) can lose the formatting if the user clicks on a column header to sort the grid.
To link other controls to the grid, use the SelectionChanged event. The RowEnter event can give the wrong behaviour, as it only fires when the focus box enters a row. Again, sorting by clicking on a column header can cause unpredictable behaviour.
To retrieve a DataRow from a databound grid, use: DirectCast(mydatagridview.Rows(i).DataBoundItem, DataRowView).Row

## See Also

* dotnetperls.com datagridview VB.NET
* dotnetperls.com datagridview C#
# Visual Basic .NET/Enumerations
## Introduction

An enumeration is a set of related constants defined by a value type. By default, an enumeration is set to integer and sets the first constant to 0 and the second to 1 and so forth. This is so when values have not been declared.

## Setting Enumerations

An enumeration that is set up with values 0, 1 and 2. (Values are set to integer as data type has not been declared):
An enumeration that sets the constants to 30, 60 and 90.

## Using Enumerations

To use an enumeration, you have to call up the enumeration collection name first. Then, like looking into the methods of a class, you then declare the enumeration that you want to use.
# Visual Basic .NET/Assignation and comparison operators
## Assignment

The "=" operator is used for assignment. The operator also serves as a comparison operator (see Comparison).
* To set values:
You can use variables in the equal operator, as well.

## Comparison

The "=" operator is used for comparison. The operator also serves as a assignation operator (see Assignment).
* To compare values:
You can use variables in the equal operator, as well.
Let's try a slightly more advanced operation.
You will get an error if you try to assign a constant or a literal a value, such as 7 = 2. You can compare 7 and 2, but the answer will always be False.
In the case of two equal operators appearing in a statement, such as
The second equal operator will be processed first, comparing 2 and 7, giving a False. Then the first equal operator will be processed, assigning False to x.

### More Comparison Operators

(x less than y), (x more than y), (x not equal to y), (x less than or equal y) & (x greater than or equal to y)
Note the way round the operators are on the last two, putting them the other way round is not valid.
# Visual Basic .NET/Binary operators

VB.Net has several Binary Operators like '=', '<', '>', '<=', '>=' and '!=' which can be used in comparisons that evaluate to a boolean value. More complex expressions could be formed by using the binary operators with logical operators like 'AND', 'OR', 'NOT' and 'XOR'.
Example: The following example shows a code snippet to compare two variables and output the result in the Console Window
# Visual Basic .NET/Collections

VB.NET supports a number of data structures called Collections. Collection can be either zero or one based, depending on how they are declared. A collection is similar to an array in that it can store multiple data entries. However, most collections have advanced methods associated with them that distinguish them from Arrays. Some of these collections are:

## ArrayList

An ArrayList is a dynamic array, the size increases and shrinks when needed and stores elements as generic Object's, this provides us with the ability to store objects with differing types.

### Add method

To add objects to the ArrayList use the System.Collections.ArrayList.Add(Object) method The following is an example of adding String objects to an Arraylist.

## Queue

A queue is a first-in/first-out style collection. A queue has two unique methods used to enqueue and dequeue information from it. Using the System.Collections.Queue.Enqueue method, an object can be added to the end of the collection. Items can later be removed using the System.Collections.Queue.Dequeue method. This method will take the first object in the queue collection and then remove it from that collection.

## Stack

A stack is a last-in/first-out style collection. A stack has three unique methods used to store and retrieve information from it. Using the System.Collections.Stack.Push method, an object can be added to the top of the stack, pushing the objects below it lower into the stack. Items can later be removed from the stack using the System.Collections.Stack.Pop method. This method will return the object at the top of the stack and remove it from the stack. Another method, System.Collections.Stack.Peek, is similar to the Pop method except it returns the object without removing it from the stack.

## SortedList

A SortedList collection is a collection of objects that are sorted both by index (similar to an array) and by key. A key works in a manner similar to that of an index; however, unlike an index, a key can be any object.

## Generics

Generics provide data structures that work for a variety of data types. While the collections discussed above store items as objects, generic collections store the values in a more specific type such as String or Integer.

### List

A List(Of Type) allows a set of values to be accessed by index or as a collection. You can therefore mix array and collection syntax on the same set:
# Visual Basic .NET/Components
## Timer in .NET

A timer is one of many components that are non-visible within the runtime of a program. A timer is used to create a sub-like operation that repeats with interval of N milliseconds. The commands within the timer can only run when the timers enabled property is set to true. This can be done by using the following code:
This code is usually put in a "on click" handler but it can also be used in almost any other handler. To put a timer into your project you must first drag and drop the timer icon from the tool box into your form and then click the timer twice where it is shown under the form to modify the code within it, then you can change the properties accordingly.
Interval
The Interval property is the amount of milliseconds set between each tick this can be changed through the properties panel or be set through the following code
Enabled
The enabled property is the Boolean property in which the status of the timer is set. This can be changed through the properties or through the following code
# Visual Basic .NET/Exception handling
## Exception handling

There are two main ways to handle errors in code, in order to avoid to stop the program when they occur.

### On Error GoTo

The older method used in VBA is "unstructured" error handling, still available via the On Error GoTo syntax, because it uses a Goto toward a label. This is still useful in certain circumstances where you wish to Resume processing after handling the error.
To avoid to define the labels, it's possible to simply ask to ignore all errors, during a certain time, and reactivate them with On Error GoTo 0:

### Try...Catch...Finally

"Structure error handling" is available with the newer Try...Catch...Finally syntax. Various error conditions are implemented via inheritors of the base Exception class.
HINT: If you wish to re-throw an exception inside a Catch block, use the Throw keyword without any arguments (particularly, do not use "Throw ex"). The Throw keyword resets the .StackTrace property of the exception object if an argument is supplied. Throw, without any arguments inside a Catch block will re-throw the error without resetting the .StackTrace property.
* ↑ Eric Lippert's Blog
# WebObjects/EOF/Using EOF/Bulk Operations
### Overview

The standard techniques for using EOF can potentially break down when you are dealing with extremely large datasets. The techniques described here are useful for taking advantage of EOF's benefits while not at the same time running out of memory.
There is quite a bit of overlap between this topic and the Memory Management section. It is recommended that you review the general memory management methodologies prior to reading this.

### Moving Large Amounts of Data Between Databases
#### Chuck Hill

Call unlock then dispose on the ec, then set the reference to null, then force garbage collection with: http://java.sun.com/docs/books/tutorial/essential/system/garbage.html
You will need to do this often with a large database, maybe more than once per entity. I don't know if that would work while maintaining the object graph.

#### Pierce T Wetter III

There used to be an EOUtil that could do something like this. Does that still exists?
Otherwise, it depends on how the ER relationship chart works. In our case, we have a set of objects that would more or less "own" all the other objects in the ER tree. So the code would look something like this:
Using the local EC is the key.
If you have a large number of master objects enough that you can't load all of them into memory at once, then it gets trickier. One way is to just fetch a list of primary keys using raw rows, then use objectWithPrimaryKeyValue to build the objects in the local editing context.
If your ER tree is more complex (there is no "owner" object, then YMMV).

#### EOImportExportApplication from Cassini

Cassini is available at Sourceforge.

#### Anjo Krank

There is some stuff in Wonder's ERXJDBCUtilities that should be able to copy from one DB to another. I never tried it, but maybe it gives you some hints. There is no real need to use EOs anyway as you just want to copy the data.

#### David Teran

Hmpf! 'that should be able to copy from one DB to another.' NoNo, Anjo, that is not fair ;-)
In fact it works perfectly -if- the JDBC driver is not buggy. Here is a quick documentation:
OK, you need to use ERExtensions and ERJars. Not a big deal, drop me a line and i'll send a demo app to you.
Then you need this code here, the example takes data from frontbase and saves it to a postgres database:
Thas all!

#### BulkMover from 360works

BulkMover provides these capabilities, though it is a ProjectBuilder project.
# WebObjects/EOF/Using EOF/Compound Primary Keys
#### Sacha Mallais

Generally avoid them. However, when you need them you can usually use the Propagate Primary Key feature to avoid having to do anything fancy.
Writing a delegate to generate PKs from the database is not a bid deal (see GVCEOFExtensions for an example of an integer PK caching delegate).
# WebObjects/EOF/Using EOF/Batch Fetching
### Batch Fetching
#### Petite Abeille

Here is a little example about how to batch fetch a bunch of EOFaults:
* First, given an array of faults, how to retrieve meta information
without triggering the fault:
* Second, for each EOFault build a qualifier:
* Finally, resolve the qualifier:
* Attached is the entire method.

#### Jonathan Rochkind

Can you explain the advantages of fetching faults instead of just letting the editingContext return them? -SamBarnum
A 'fault' will not actually be fetched until it is asked for. It's just an object in memory that says 'if anyone tries to access my data, I will fetch it from the db.' You usually don't run into a situation where you want to create faults instead of just fetching objects from the EC---but when you're doing complicated programming, it will be obvious when you do. I think just once have I actually manually created faults. [When I had a semantic relationship, but couldn't actually model the relationship, and implemented a sort of half baked relationship scheme of my own instead.]
However, I'm not sure why you'd want to use the above code when the EOEditingContext method faultForRawRow is available. Make an NSDictionary which has pk attribute names as keys and desired values as their values, pass it to yourEC.faultForRawRow?, you've got a fault. A heck of a lot easier than the above.

### Preloading Relationships

This method can be used to prefetch relationships in a batch instead of having them fire one by one. This can be used to fine tune batch fetching in code instead of doing it in the model. Be careful of how you use this method. It will force a fetch from the database even if the objects are already cached in the object store. Used incorrectly this can reduce, instead of increase, performance.
# WebObjects/EOF/Modeling/Prototypes
### Overview

Prototypes are EOF's mechanism for database-agnostic modeling. By including an EOModel that has an entity with the special name "EOJDBCDatabaseVendorPrototypes" (like EOJDBCFrontBasePrototypes, or EOJDBCOraclePrototypes), or the fallback general prototype "EOJDBCPrototypes," you can define reusable type definitions. For instance, you might declare a type definition "money" that maps to a floating point number with precision 32 and scale of 2, but different database have different names and syntaxes for this. With prototypes, your model simple refers to its prototype "money" for its type, and the prototype define the rest, and can we switched according to the database you are using.
Because prototypes centralize your type information, it also makes it much easier to make bulk changes to your types. For instance, if you declare an "address" type to be a varchar(50) and realize it's not enough, you can simply change your prototype to varchar(100) and all of your types inherit the change.

#### Chuck Hill

A model without prototypes is, um, dumb. A reusable framework without prototypes is not reusable. See Practical WebObjects pages 45 - 55 for a discussion of this and code. There is some very superficial discussion in the EOModeler docs.

#### Anjo Krank

[Project Wonder has] neat code that allows you to switch then based on properties and not on the mumbo-jumbo that normally gets used. And we allow you to actually support multiple types of DBs, which is not possible with the EOJDBCPrototypes. However, I'd advice prototypes only when you have either only one model or are very disciplined:

### Gotchas

EOModeler is not without its faults. It is, in particular, quite finicky about prototypes. The minor pains are, however, worth it.

#### Framework? What Framework.

EOModeler must have a .pbproj or a .xcode build folder in the path that you open the model from, or it will not be able to load other frameworks (in particular, prototype frameworks).

#### The Brown Column of Death

If you ever change the prototype of a previously defined column, you might notice the column name in your EOModel turns brown. Any column that is brown in your model is going to be defined by the prototype, but you may have noticed you typically don't define column names in your prototype. As a result, when you save your model, it will BLANK your column name.
If a column DOES get blanked, it results in a TERRIBLY annoying and useless error message from inside of EOF. I believe you get a ClassCastException from SQL generation from a method that is named something about creating a comma separated list from an NSArray (I don't have the exception around offhand). So if you ever see a ClassCastException from way down in EOF, log this note away because it will save you much pain trying to debug it.
It is best to always select the prototype first, then fill in the rest of the column. It has the least potential for annoying EOModeler bugs in exchange for a small behavioral change. If the column turns brown, you will need to rename the column and then change it back to "unbrown" it.
# WebObjects/EOF/Modeling/Inheritance

Entity inheritance is a way to take advantage of the object-relational mapping layer between the EOEntity objects and the table structure in the database to provide flexibility. This flexibility can also become a source of problems, so care must be taken when using this feature. There are many tricks available from the flexibility this feature provides.
There are three kinds of entity inheritance that represent different ways to map a table or tables to an entity or entities.

## Single-Table Inheritance

In single-table inheritance, a single table can be used for more than one entity. The most sure way to do this is to use a column, or a set of columns, that have ordinal values.
An example would be:
Table: Sellables :
| pk | name | cost | objType |
| 1 | Corvette | 50000 | 1 |
| 2 | Volkswagen | 10000 | 1 |
| 3 | Piper Cub | 50000 | 2 |
| 4 | Lear Jet | 100000 | 2 |
One can create two entities. In one entity, called "Cars", the external name would be "Sellables" and there would be a restricting qualifier saying that "objType = 1". For another entity, called "Planes", the external name would also be "Sellables" and there would be a restricting qualifier saying that "objType = 2".
When instances of the Cars or the Planes entity are created, one must make sure to set the objType attribute. It is often simplest to have custom EO classes for the entities that can handle the initiation reliably.
# WebObjects/EOF/Using EOF/Common Pitfalls and Troubleshooting
### Deadlocks

The most common cause of this is EOEditingContextLock but you can also cause problems by leaving locks on the EODatabaseContext. To find out where you are locking improperly you will need to start tracking editing context locks. Review the Context and Database Locking section for more information.

### Subclass Missing Primary Key

If you are subclassing across EO models and EOF is not generating a primary key in SQL when you insert your subclass (the result would be an integrity violation for a null primary key), then you have likely run into the annoying behavior of EOF when dealing with models that have SLIGHTLY different connection dictionaries. Basically, EOF decides when to share EODatabases across multiple models by comparing the connection dictionaries. However, gggthe connection dictionary contains a large block named jdbc2Info with cached type and driver information. If you happened to create your models with, for instance, different jdbc driver versions, that version number will cause the dictionaries to not be equals. When this occurs, EOF assigns each model to its own EODatabase, which causes SQL generation for the subclass entity to enter a codepath that ends up not generating a primary key. Chuck Hill recommends removing jdbc2Info at runtime to prevent problems like this from occurring.

### No Suitable Driver Found

If you get the following exception:
Odds are very good that your classpath is incorrect. There are two parts to database support in EOF, the JDBC driver, and the Database Plugin. You must make sure that BOTH are in your classpath. For instance, on FrontBase, you must have both frontbasejdbc.jar AND frontbaseplugin.jar (from the FrontBasePlugin.framework) in your classpath.
# XQuery/Simple RSS reader

The BBC provides a wide range of RSS news feed, e.g. UK Educational news

## News Page

Reformat the RSS feed as HTML:
Execute

## Text-to-Speech

The Opera browser with Voice extension supports text-to-speech, allowing this news to be spoken. This uses the XML vocabularies VoiceXML and XML Events. [2019-01-26 : Sadly Opera no longer supports VoiceXML]
Execute
Note that the html namespace has been given a prefix, so that the default prefix can refer to the RSS feed.

## Generic RSS reader

More generally, a reader which could voice any RSS feed would be a useful service.
UWE news Execute
# XQuery/Southampton Pubs
## Pubs of Southampton

Data on Pubs in Southampton has collected by a couple of enthusiasts. John Goodwin created an RDF representation of this data and an interface to the data.

## Conversion to KML

The RDF is straightforward to convert to KML. The RDF uses a number of namespaces, not all of which are used in this extract.
March 2009: This script was discovered to be broken. The base RDF file has been changed to add a new namespace for addresses in place of the local pub namespace. Since there is of course no notification of such changes, the user of published RDF data sets is not in a much better position than the web scraper, unless the application is written to first check that the vocabulary assumed by the application is still used. However there is no mechanism for expressing the mixture of bits of vocabs used in a RDF dataset. If there were, at least the interfaces could be checked by having a similar definition of the parts actually used in this application to compare.
5 March 2008
Sadly John has been forced to take down this data set due to adverse reaction to one of the pub reviews.
On GoogleMap
# XQuery/Special Characters
## Motivation

You want to control where you put special characters such as newlines and quote characters in your XML files.

## Method

We will create XQuery variables (referents) to the decimal encoded character values using the &#NN; notation where NN is the decimal number for this character in the character set. We can then add these variables anywhere in the output stream.

## Example Program

In this example we will create a variable $nl had have it refer to the newline character. We will then put this in the middle of a string.
Returns:
The following shows how both quote and newline special characters can be created.
Returns:
Note that the string length of these variables string-length($nl) and string-length($quote) is only one character.

## Using Zero Width Space Characters for Line Breaks

If you have URLs that appear in the text to ensure they break gracefully when hyphenation is enabled:
Contributed by Joe Wicentowski in March of 2014

## References

For other characters see the following table:
* List of XML and HTML character references
* list of ASCII characters
* XQuery module for encoding many special characters