Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
Passaggio riferimenti
lunedì 11 gennaio 2010 - 14.48
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
iif
Profilo
| Expert
713
messaggi | Data Invio:
lun 11 gen 2010 - 14:48
Ciao, è possibile richiamare una sub passando come riferimento il nome del form?
Vi posto l'esempio:
Sub CaricaAnagrafica(ByVal xIDPers, ByRef Chiamante)
Using miaConnessione As New OleDb.OleDbConnection(Connessione.ConnectionString)
Dim command As New OleDb.OleDbCommand("Select * From TPers Where ID=" & xIDPers, miaConnessione)
Attendi(True)
miaConnessione.Open()
Dim Lettore As OleDb.OleDbDataReader = command.ExecuteReader()
Lettore.Read()
Chiamante.txtMatricola.Text = Lettore("Matricola").ToString()
Chiamante.txtNome.Text = Lettore("Nome").ToString()
Chiamante.txtOre.Text = Lettore("PlanOre").ToString()
Chiamante.txtProgressivo.Text = Lettore("ID").ToString()
Chiamante.txtCap.Text = Lettore("Cap").ToString()
Chiamante.txtCitta.Text = Lettore("Citta").ToString()
Chiamante.txtIndirizzo.Text = Lettore("Indirizzo").ToString()
Chiamante.txtMail.Text = Lettore("PostaElettronica").ToString()
Chiamante.txtCodFisc.Text = Lettore("CodFisc").ToString()
For x = 0 To Lettore("Glav").ToString.Length - 1
If Lettore("Glav").ToString.Substring(x, 1) = "L" Then
Chiamante.Lun.Checked = True
ElseIf Lettore("Glav").ToString.Substring(x, 1) = "M" Then
Chiamante.Mar.Checked = True
ElseIf Lettore("Glav").ToString.Substring(x, 1) = "W" Then
Chiamante.Mer.Checked = True
ElseIf Lettore("Glav").ToString.Substring(x, 1) = "G" Then
Chiamante.Gio.Checked = True
ElseIf Lettore("Glav").ToString.Substring(x, 1) = "V" Then
Chiamante.Ven.Checked = True
ElseIf Lettore("Glav").ToString.Substring(x, 1) = "S" Then
Chiamante.Sab.Checked = True
ElseIf Lettore("Glav").ToString.Substring(x, 1) = "D" Then
Chiamante.Dom.Checked = True
End If
Next
Lettore.Close()
End Using
Attendi(False)
End Sub
Grazie.
AntCiar
Profilo
| Expert
936
messaggi | Data Invio:
lun 11 gen 2010 - 16:35
Ciao
Certo che s può fare.
Devi specificare anche il tipo
es: .... byref chiamante as Form2
Cristian Barca
Jeremy
Profilo
| Guru
1.527
messaggi | Data Invio:
lun 11 gen 2010 - 21:23
Ciao Fabio.
Aggiungo che non è necessario specificare la clausola ByRef in quanto in .Net viene passato comunque tutto come riferimento(e non come valore) ad eccezione di variabili di tipo primitivo(parti integranti del linguaggio) quali String, Integer etc... ....... e se posso darti un consiglio imposta nei tuoi progetti futuri OptionStrict On così da evitare associazioni tardive che potrebbero creari errori di conversione a run-time.
Facci sapere....
Ciao
iif
Profilo
| Expert
713
messaggi | Data Invio:
mar 12 gen 2010 - 00:21
Grazie per le risposte, ho provato come avete detto nelle risposte, mi dice che non trova il campo txtmatricola
AntCiar
Profilo
| Expert
936
messaggi | Data Invio:
mar 12 gen 2010 - 08:37
Ciao
Questo è un problema di "visibilità"
Imposta la visibilità di txtmatricola a "public"
Cristian Barca
iif
Profilo
| Expert
713
messaggi | Data Invio:
mar 12 gen 2010 - 13:48
Funziona, grazie.
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !