1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
Module Module1
Public MaxEmploye As Integer = 4 'compteur
Public ArrEmployes(MaxEmploye - 1) As Employe 'note le -1 sinon vb.net cree un tableau de 5 elements(en csharp on met 4 tout court)
Public Structure DDN
Public Jour As Integer
Public Mois As String
Public Anne As Integer
End Structure
Public Structure Employe
Public Nom As String
Public Salaire As Double
Public DateNaissance As DDN
Public Sub New(ByVal ONom As String, ByVal OSalaire As Double, ByVal OJour As Integer, ByVal OMois As String, ByVal OAnne As Integer)
Nom = ONom
Salaire = OSalaire
DateNaissance.Jour = OJour
DateNaissance.Mois = OMois
DateNaissance.Anne = OAnne
End Sub
End Structure
'Sub Main()
' Dim p1 As New Employe("Sarah", 7500, 28, "mars", 1979)
' ArrEmployes(N) = p1
' Dim p2 As New Employe("Nadine", 55000, 17, "fevrier", 1983)
' ArrEmployes(N) = p2
' Dim p3 As New Employe("kamal", 54500, 20, "avril", 1980)
' ArrEmployes(N) = p3
' Dim p4 As New Employe("Jacques", 56000, 2, "juin", 1985)
' ArrEmployes(N) = p4
' Affiche(ArrEmployes)
'End Sub
Public Sub Affiche(ByVal arrEmp() As Employe)
For i As Integer = 0 To arrEmp.Length - 1
Console.WriteLine("votre nom est: " & arrEmp(i).Nom & " et vous gagnez: " & arrEmp(i).Salaire & " Dh.")
Console.WriteLine("vous etes ne (e) le " & arrEmp(i).DateNaissance.Jour & " " & arrEmp(i).DateNaissance.Mois & " " & arrEmp(i).DateNaissance.Anne)
Console.WriteLine("===========================================")
Next
End Sub
End Module
'le form
'LE FORM
Imports System.Text
Public Class frmStracomma
Private tempArray() As Employe
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p1 As New Employe("Sarah", 7500, 28, "mars", 1979)
Dim p2 As New Employe("Nadine", 55000, 17, "fevrier", 1983)
Dim p3 As New Employe("kamal", 54500, 20, "avril", 1980)
Dim p4 As New Employe("Jacques", 56000, 2, "juin", 1985)
Dim p5 As New Employe("Jacquot", 1000, 2, "aout", 1993)
Dim p6 As New Employe("Abacus", 12000, 13, "decembre", 2001)
tempArray = New Employe() {p1, p2, p3, p4, p5, p6}
Array.Copy(tempArray, ArrEmployes, ArrEmployes.Length)
Affiche(ArrEmployes)
End Sub
Private sb As New StringBuilder
Private Sub Affiche(ByVal arrEmp() As Employe)
sb.Clear()
For i As Integer = 0 To arrEmp.Length - 1
sb.AppendLine("votre nom est: " & arrEmp(i).Nom & " et vous gagnez: " & arrEmp(i).Salaire & " Dh.")
'Console.WriteLine("votre nom est: " & arrEmp(i).Nom & " et vous gagnez: " & arrEmp(i).Salaire & " Dh.")
sb.AppendLine("vous etes ne (e) le " & arrEmp(i).DateNaissance.Jour & " " & arrEmp(i).DateNaissance.Mois & " " & arrEmp(i).DateNaissance.Anne)
'Console.WriteLine("vous etes ne (e) le " & arrEmp(i).DateNaissance.Jour & " " & arrEmp(i).DateNaissance.Mois & " " & arrEmp(i).DateNaissance.Anne)
sb.AppendLine("===========================================")
'Console.WriteLine("===========================================")
Next
sb.AppendLine(" les recrutements sont supendus pour cause de crise....!!!")
TextBox1.Text = sb.ToString
End Sub
End Class |
Partager