vbdotnet.it

Tricks & tips, workaround, forum and ideas with .Net

About the author

Enrico Rossini è il gestore di questo blog.
E-mail me Send mail

Recent posts

Recent comments

Contributi

Best 6 ~ 6 users ~ 6 comments

Info legali

Le opinioni espresse in questo blog sono strettamente personali e ogni persona è responsabile dei commenti che inserisce. I marchi citati sono delle rispettive aziende.

© Copyright 2010

Advertising


Come muovere gli elementi di un listbox con dei bottoni su e giù?

In un form aggiungiamo il ListBox con nome ListBox1 e 4 bottoni con nome cmdUp, cmdDown, cmdAdd, cmdRemove.

   1:  Private Sub cmdAdd_Click()
   2:     ' aggiunge un nuovo elemento
   3:     ListBox1.AddItem "Item " & CStr(ListBox1.ListCount + 1)
   4:  End Sub
   5:   
   6:  Private Sub cmdRemove_Click()
   7:     ' rimuove un elemento
   8:     If ListBox1.ListIndex > -1 Then
   9:        ListBox1.RemoveItem ListBox1.ListIndex
  10:     End If
  11:  End Sub
  12:   
  13:  Private Sub cmdUp_Click()
  14:     Dim sText As String
  15:     Dim iIndex As Integer
  16:   
  17:     ' verifica se solo un elemento è selezionato
  18:     If ListBox1.SelCount = 1 Then
  19:        If ListBox1.ListIndex = 0 Then Exit Sub
  20:   
  21:        ' salva l'elemento da spostare
  22:        sText = ListBox1.List(ListBox1.ListIndex)
  23:        iIndex = ListBox1.ListIndex
  24:   
  25:        ' rimuove l'elemento
  26:        ListBox1.RemoveItem ListBox1.ListIndex
  27:   
  28:        ' aggiunge l'elemento una posizione più in alto
  29:        ListBox1.AddItem sText, iIndex - 1
  30:   
  31:        ' viene selezionato l'elemento spostato
  32:        ListBox1.Selected(iIndex - 1) = True
  33:     End If
  34:  End Sub
  35:   
  36:  Private Sub cmdDown_Click()
  37:     Dim sText As String
  38:     Dim iIndex As Integer
  39:     ' verifica se solo un elemento è selezionato
  40:     If ListBox1.SelCount = 1 Then
  41:        If ListBox1.ListCount - 1 = ListBox1.ListIndex Then Exit Sub
  42:   
  43:        sText = ListBox1.List(ListBox1.ListIndex)
  44:        iIndex = ListBox1.ListIndex
  45:   
  46:        ListBox1.RemoveItem ListBox1.ListIndex
  47:        ListBox1.AddItem sText, iIndex + 1
  48:        ListBox1.Selected(iIndex + 1) = True
  49:     End If
  50:  End Sub

Buon lavoro!

Currently rated 5.0 by 4 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Sunday, November 23, 2008 10:38 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Aggiungere una riga ad una tabella di un dataset

Alle volte può essere utile utilizzare un dataset ed aggiungere a questo una riga vuota ad una delle tabelle esistenti. Nell'esempio corrente dbPubs è il nostro dataset.

   1:  Dim dsPubs As New DataSet()
   2:  Dim r As DataRow
   3:  r = dsPubs.Tables(0).NewRow
   4:  dsPubs.Tables(0).Rows.Add(r)

Ciao a tutti!

Currently rated 3.5 by 2 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Sunday, November 23, 2008 1:07 PM
Permalink | Comments (0) | Post RSSRSS comment feed

SQL: convert date in string

Come riuscire a convertire direttamente da SQL un valore datetime in una stringa nel formato voluto? Attraverso questo semplice comando e con la lista seguente è possibile scegliere il tipo di formato data che si vuole.

   1:  CONVERT(varchar, CampoData, 103) AS Valore

Tabella di conversioe

Senza il secolo (aa) Con il secolo (aaaa) Standard Input/Output

-

0 o 100

Valore predefinito

mes gg aaaa hh:miAM (o PM)

1

101

U.S.

mm/gg/aaaa

2

102

ANSI

aa.mm.gg

3

103

Inglese Regno Unito/Francese

gg/mm/aaaa

4

104

Tedesco

gg.mm.aa

5

105

Italiano

gg-mm-aa

6

106

-

gg mes aa

7

107

-

Mes gg, aa

8

108

-

hh:mi:ss

-

9 o 109

Valore predefinito + millisecondi

mes gg aaaa hh:mi:ss:mmmAM (o PM)

10

110

USA

mm-gg-aa

11

111

Giapponese

aa/mm/gg

12

112

ISO

aammgg

aaaammgg

-

13 o 113

Valore predefinito Europa + millisecondi

gg mes aaaa hh:mi:ss:mmm(24h)

14

114

-

hh:mi:ss:mmm(24h)

-

20 o 120

ODBC canonico

aaaa-mm-gg hh:mi:ss(24h)

-

21 o 121

ODBC canonico (con millisecondi)

aaaa-mm-gg hh:mi:ss.mmm(24h)

-

126

ISO8601

aaaa-mm-ggThh:mi:ss.mmm (senza spazi)

-

127

ISO8601 con fuso orario Z.

aaaa-mm-ggThh:mi:ss.mmmZ

(senza spazi)

-

130

Hijri

gg mes aaaa hh:mi:ss:mmmAM

-

131

Hijri

gg/mm/aa hh:mi:ss:mmmAM

 

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Tuesday, November 11, 2008 5:22 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Differenza tra SQL Server Express e Compact Edition

La principale differenza è che SQL Server Express gira su sistemi Windows Desktop mentre la Compact Edition è progettata fondamentalmente per dispositivi mobili. Nel documento allegato Microsoft spiega dettagliatamente le funzionalità della famiglia SQL Server e le differenze tra i due sistemi.

Compact_Express_Comparison.pdf (535,32 kb)

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Generalità | Documenti
Posted by enrico on Thursday, November 06, 2008 3:38 PM
Permalink | Comments (0) | Post RSSRSS comment feed