Traduire ce code de VB a C#
salma ritaje
Messages postés
8
Statut
Membre
-
salma ritaje Messages postés 8 Statut Membre -
salma ritaje Messages postés 8 Statut Membre -
bonjour a tous je veux traduire ce code de VB a C#
et quelle est le langage Le plus utilisé C# ou VB et merci d'avance
Private Sub Btn_Ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Ajouter.Click
Try
Dim s As New Stagiaire
s.Nom = Txb_Nom.Text
s.Prenom = Txb_Prenom.Text
If RB_M.Checked = True Then
s.Sexe = CChar("M")
Else
s.Sexe = CChar("F")
End If
s.Optionn = CB_Option.Text
s.Age = CInt(NUD.Value)
liste_stagiaire.Add(s)
afficher_dansDG()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub BTn_Supprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTn_Supprimer.Click
Try
Dim indice_s As Integer = DataGridView1.CurrentRow.Index
If indice_s = liste_stagiaire.Count Then
Throw New Exception("Vous devez selectionnez une ligne")
End If
If indice_s <> liste_stagiaire.Count Then
If MessageBox.Show("Etes vous sur de vouloir supprimer le stagiaire selectionné", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
liste_stagiaire.RemoveAt(indice_s)
MessageBox.Show("Opération effectuée", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
MessageBox.Show("Opération annulé", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
afficher_dansDG()
Catch erreur As Exception
MsgBox(erreur.Message)
End Try
End Sub
Private Sub Btn_Rechercher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Rechercher.Click
Dim nom As String = Txb_Nom.Text
DataGridView1.Rows.Clear()
For Each st As Stagiaire In liste_stagiaire
If st.Nom = nom Then
Txb_Nom.Text = nom
Txb_Prenom.Text = st.Prenom
If RB_F.Checked = True Then
RB_F.Checked = True
Else
RB_M.Checked = True
End If
CB_Option.Text = st.Optionn
NUD.Value = st.Age
End If
Next
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
End Class
et quelle est le langage Le plus utilisé C# ou VB et merci d'avance
Private Sub Btn_Ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Ajouter.Click
Try
Dim s As New Stagiaire
s.Nom = Txb_Nom.Text
s.Prenom = Txb_Prenom.Text
If RB_M.Checked = True Then
s.Sexe = CChar("M")
Else
s.Sexe = CChar("F")
End If
s.Optionn = CB_Option.Text
s.Age = CInt(NUD.Value)
liste_stagiaire.Add(s)
afficher_dansDG()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub BTn_Supprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTn_Supprimer.Click
Try
Dim indice_s As Integer = DataGridView1.CurrentRow.Index
If indice_s = liste_stagiaire.Count Then
Throw New Exception("Vous devez selectionnez une ligne")
End If
If indice_s <> liste_stagiaire.Count Then
If MessageBox.Show("Etes vous sur de vouloir supprimer le stagiaire selectionné", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
liste_stagiaire.RemoveAt(indice_s)
MessageBox.Show("Opération effectuée", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
MessageBox.Show("Opération annulé", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
afficher_dansDG()
Catch erreur As Exception
MsgBox(erreur.Message)
End Try
End Sub
Private Sub Btn_Rechercher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Rechercher.Click
Dim nom As String = Txb_Nom.Text
DataGridView1.Rows.Clear()
For Each st As Stagiaire In liste_stagiaire
If st.Nom = nom Then
Txb_Nom.Text = nom
Txb_Prenom.Text = st.Prenom
If RB_F.Checked = True Then
RB_F.Checked = True
Else
RB_M.Checked = True
End If
CB_Option.Text = st.Optionn
NUD.Value = st.Age
End If
Next
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
End Class
A voir également:
- Traduire ce code de VB a C#
- Code ascii - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code puk bloqué - Guide
- Code activation windows 10 - Guide
- Comment traduire un site en français - Guide
2 réponses
Sinon je te conseil d'apprendre C# car celui ci te facilitera l'apprentissage des autres langages tel que le C, C++, Java ect ayant la même syntaxe.