You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
$testVar = "OK";
$resultVar;
$resultVar = $testVar=="OK" ? true : false;
// same as if-else construction
if ($testVar == "OK")
{
$resultVar = true;
}
else
{
$resultVar = false;
};
22
VB.NET
GUI, Tabelle
Tabellenselektion
' DataGridView
' Man bekommt den Index der Column und der Row
Dim counter As Integer
For counter = 0 To (DataGridView1.SelectedCells.Count - 1)
MessageBox.Show(DataGridView1.SelectedCells(counter).ColumnIndex.ToString & vbCr & DataGridView1.SelectedCells(counter).RowIndex.ToString)
Next
23
VB.NET
GUI, Datenbank
ComboBox mit Datenbank
' Die Datenbank-Tabelle enthält die Felder titel und id
Dim dt As Data.DataTable = myDataTable ' Die DataTable wurde bereits gefüllt aus der Datenbank...
comboBox1.DataSource = dt
comboBox1.DisplayMember = "titel" ' Der angezeigte Wert für den Benutzer
comboBox1.ValueMember = "id" ' Der Wert, den der Benutzer auswählt (id)
Dim ausgewaehlteIdAusComboBox As String
ausgewaehlteIdAusComboBox=comboBox1.SelectedValue.ToString ' enthält die ausgewählte id
266
MS Access VBA
Array
Dictionary Basics
' empty dict
Dim myDict As Dictionary
Set myDict = New Dictionary
' some static values
myDict.Add "key1", "value1"
myDict.Add "key2", "valueY"
myDict.Add "keyX", "value98"
' update a key programmatically
myDict.Remove "key1"
myDict.Add "key1", "new value"
' iterate
Dim strKey As Variant
Dim current_key As String
Dim strValue As String
For Each strKey In myDict.Keys()
current_key = strKey
strValue = myDict.Keys(strKey)
Next
' Exists
If myDict.Exists(strKey) Then
Debug.Print "yes"
End If
' get an specific item
Dim subdict As String
subdict = myDict.Keys("key2")
# valueY
' Using IF(IIF) logic in Derived Column
(LEN(TRIM(Test)) > 0 ? SUBSTRING(Test,1,5) : NULL(DT_WSTR,5))
261
T-SQL
Datenbank
CTAS
-- Achtung, er werden nur Felder mit Datentypen übernommen.
-- Keine Constraints (PK, FK, Defaults, ...) oder IDENTITY Informationen
-- Sollte die Zieltabelle (myDestinationTable) bereits vorhanden sein, kommt es zu einer Fehlermeldung
SELECT
*
INTO myDestinationTable
FROM mySourceTable
148
PL/pgSQL
Strings
Strings miteinander verbinden
-- Bei PL/pgSQL sollte man die Funktion concat verwenden.
-- Felder verbinden mit || kann zu NULL im Ergebnisfeld führen
SELECT
field_a
,field_b
,NULL as field_c
,concat(field_a, field_b, field_c) as together
FROM
table_1
59
T-SQL
Datenbank
Fortlaufende Nummer innerhalb eines ResultSets
-- Beispiel:
-- http://msdn.microsoft.com/de-de/library/ms186734.aspx
SELECT FirstName, LastName, ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS 'Row Number', SalesYTD, PostalCode FROM Sales.vSalesPerson