[visual basic6.0

doumbia ibrahima -  
 FD -
Bonjour
je suis un jeune de 21ans en informatique de gestion premiere annee.j'aimerais connaitre la base de fonctionnement du langage visual basic6.0.et une bonne documentation.
Configuration: visual basic6.0

2 réponses

  1. FD
     
    salut moi aussi je programme un peu sa peut peut- etre t'aider ceci...
    mais c 6.0 et faut decripter (je me comprent pas moi meme des fois...

    Private Sub Command1_Click()
    Form1.TabStrip1.Visible = True
    End Sub

    Private Sub Command2_Click()
    Form1.TabStrip1.Visible = False
    End Sub

    metter un tabstrip metter le en visible true (invisible) metter un bouton (ou deux )et taper le code ci-dessus

    Private Sub loadgame_Click()
    With CommonDialog1
    .DialogTitle = "Ouvrir"
    .CancelError = False
    'À faire : Définir les indicateurs et les attributs du contrôle des dialogues communs
    '.Filter = "Tous les fichiers (*.*)|*.*"
    .Filter = "Fichier Sauvegarde Serpent (*.FSS)|*.FSS"
    .ShowOpen
    If Len(.FileName) = 0 Then
    Exit Sub
    End If
    sFile = .FileName
    End With
    'À faire : Ajouter le code de traitement du fichier ouvert

    End Sub

    Pour faire marcher ce code il vous faut aussi rajouter un Timer et une statusbar
    Et modifier le code ci-dessous a: ("C:\ Vous devez mettre le nom de votre image et modifier le nom du lecteur si besoin.
    Form2.Image1.Picture = LoadPicture("C:\Smiley\Image\Les Personnage\le perso principal\Smiley gauche.bmp")

    Dim i As Integer
    Dim dir As Integer
    Dim anc_dir As Integer

    Dim vitesse As Integer

    Private Type Smiley
    direction As Integer
    gauche As Integer
    haut As Integer
    End Type

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    anc_dir = dir

    Select Case KeyCode
    Case 37: 'case dir_gauche
    dir = 37
    Case 38: 'case dir_haut
    dir = 38
    Case 39: 'case dir_droite
    dir = 39
    Case 40: 'case dir_bas
    dir = 40
    End Select

    End Sub

    Private Sub Vitesses_Timer()
    vitesse = 25

    Select Case dir
    Case 37: 'direction gauche
    If Form2.Image1.Left > 0 And Form2.Image1.Left > vitesse Then
    Form2.Image1.Picture = LoadPicture("C:\Smiley\Image\Les Personnage\le perso principal\Smiley gauche.bmp")
    Form2.Image1.Left = Form2.Image1.Left - vitesse
    End If
    Case 38: 'direction haut
    If Form2.Image1.Top > 0 And Form2.Image1.Top > vitesse Then
    Form2.Image1.Picture = LoadPicture("C:\Smiley\Image\Les Personnage\le perso principal\Smiley haut.bmp")
    Form2.Image1.Top = Form2.Image1.Top - vitesse
    End If
    Case 39: 'direction droite
    If Form2.Image1.Left + Form2.Image1.Width < Screen.Width And Screen.Width - (Form2.Image1.Left + Form2.Image1.Width) > vitesse Then
    Form2.Image1.Picture = LoadPicture("C:\Smiley\Image\Les Personnage\le perso principal\Smiley droite.bmp")
    Form2.Image1.Left = Form2.Image1.Left + vitesse

    End If

    Case 40: 'direction bas
    If Form2.Image1.Top + Form2.Image1.Height < Form2.StatusBar1.Top And Form2.Image1.Top + Form2.Image1.Height + vitesse < Form2.StatusBar1.Top Then
    Form2.Image1.Picture = LoadPicture("C:\Smiley\Image\Les Personnage\le perso principal\Smiley bas.bmp")
    Form2.Image1.Top = Form2.Image1.Top + vitesse
    End If

    End Select

    End Sub

    Private Sub Timer1_Timer()
    If Form1.MCIWnd1.Position = Form1.MCIWnd1.Length Then
    Form1.MCIWnd1.Position = 0
    Form1.MCIWnd1.Command = "play"
    End If
    End Sub

    'Commande la musique
    Private Sub Activate_Click()
    Form1.MCIWnd1.Command = "play"
    End Sub

    Private Sub Arret_Click()
    Form1.MCIWnd1.Command = "stop"
    Form1.MCIWnd1.Position = 0
    End Sub

    Private Sub Paused_Click()
    Form1.MCIWnd1.Command = "pause"
    End Sub

    Mettez un Mciwndx sur la Form

    private sub commande1_click()
    form2.show vbmodal
    end sub

    Dim i As Integer
    Dim dir As Integer
    Dim anc_dir As Integer

    Dim vitesse As Integer

    Private Type BILLE
    direction As Integer
    gauche As Integer
    haut As Integer
    End Type

    Dim tabl(8) As BILLE

    Private Sub Form_Initialize()
    With Form1
    .WindowState = 2
    End With
    End Sub

    Private Sub Form_Load()

    Form1.MCIWnd1.Visible = False

    Form1.Label2.Visible = False

    With Form1
    .Visible = False
    .Visible = True
    .Label1.Left = (Screen.Width - Label1.Width) / 2
    .Label1.Top = (StatusBar1.Top - Label1.Height) / 2
    'Form1.Label1.Visible = True
    End With

    Form1.BackColor = &H0&
    Form1.tete.Visible = False
    Form1.boule1.Visible = False
    Form1.boule2.Visible = False
    Form1.boule3.Visible = False
    Form1.boule4.Visible = False
    Form1.boule5.Visible = False
    Form1.boule6.Visible = False
    Form1.boule7.Visible = False
    Form1.boule8.Visible = False
    Form1.StatusBar1.Visible = False

    End Sub

    Private Sub newgame_Click()
    dir = anc_dir = 0
    'affiche_serpent

    Form1.tete.Picture = LoadPicture("C:\Smiley\Image\les personnage\le perso principal\Smiley gauche.gif")
    Form1.tete.Top = 0.5 * Form1.ScaleHeight
    Form1.tete.Left = 0.8 * Form1.ScaleWidth
    Form1.BackColor = &H8000000E
    Form1.StatusBar1.Visible = True

    Form1.Label1.Visible = False

    Form1.tete.Visible = True
    Form1.boule1.Visible = True
    Form1.boule2.Visible = True
    Form1.boule3.Visible = True
    Form1.boule4.Visible = True
    Form1.boule5.Visible = True
    Form1.boule6.Visible = True
    Form1.boule7.Visible = True
    Form1.boule8.Visible = True

    Form1.boule1.Top = Form1.tete.Top + ((Form1.tete.Height - Form1.boule1.Height) / 2)
    Form1.boule1.Left = Form1.tete.Left + Form1.tete.Width
    Form1.boule2.Top = Form1.boule1.Top
    Form1.boule2.Left = Form1.boule1.Left + Form1.boule1.Width
    Form1.boule3.Top = Form1.boule2.Top
    Form1.boule3.Left = Form1.boule2.Left + Form1.boule2.Width
    Form1.boule4.Top = Form1.boule3.Top
    Form1.boule4.Left = Form1.boule3.Left + Form1.boule2.Width
    Form1.boule5.Top = Form1.boule4.Top
    Form1.boule5.Left = Form1.boule4.Left + Form1.boule2.Width
    Form1.boule6.Top = Form1.boule5.Top
    Form1.boule6.Left = Form1.boule5.Left + Form1.boule2.Width
    Form1.boule7.Top = Form1.boule6.Top
    Form1.boule7.Left = Form1.boule6.Left + Form1.boule2.Width
    Form1.boule8.Top = Form1.boule7.Top
    Form1.boule8.Left = Form1.boule7.Left + Form1.boule2.Width

    'Ici il faut faire une fonction pour que quand on fait la première fois "Nouvelle partie" il ne se passe rien et dès qu'on le refait, le programme met une MSGBOX "êtes vous sur de recommencer la partie?" avec 2 boutons (oui et non).

    vitesse = 15

    End Sub

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    anc_dir = dir

    If vitesse <> 0 Then
    Select Case KeyCode
    Case 37: 'case dir_gauche
    dir = 37
    Case 38: 'case dir_haut
    dir = 38
    Case 39: 'case dir_droite
    dir = 39
    Case 40: 'case dir_bas
    dir = 40
    Case 80: 'case paused
    vitesse = 0

    End Select
    End If

    End Sub

    Private Sub tim_deplace_Timer()
    'ce test sert a empecher le serpent de repartir sur ses pas
    If (anc_dir + 2 = dir) Or (anc_dir - 2 = dir) Then
    dir = anc_dir
    End If
    Select Case dir
    Case 37: 'direction gauche
    If Form1.tete.Left > 0 And Form1.tete.Left > vitesse Then
    Form1.tete.Picture = LoadPicture("C:\Smiley\Image\les personnage\le perso principal\smiley gauche.gif")
    Form1.tete.Left = Form1.tete.Left - vitesse
    Form1.boule1.Top = Form1.tete.Top + (Form1.tete.Height - Form1.boule1.Height) \ 2
    Form1.boule1.Left = Form1.tete.Left + Form1.tete.Width
    Form1.boule2.Top = Form1.boule1.Top + (Form1.boule1.Height - Form1.boule2.Height) \ 2
    Form1.boule2.Left = Form1.boule1.Left + Form1.boule1.Width
    Form1.boule3.Top = Form1.boule2.Top + (Form1.boule2.Height - Form1.boule3.Height) \ 2
    Form1.boule3.Left = Form1.boule2.Left + Form1.boule2.Width
    Form1.boule4.Top = Form1.boule3.Top + (Form1.boule3.Height - Form1.boule4.Height) \ 2
    Form1.boule4.Left = Form1.boule3.Left + Form1.boule3.Width
    Form1.boule5.Top = Form1.boule4.Top + (Form1.boule4.Height - Form1.boule5.Height) \ 2
    Form1.boule5.Left = Form1.boule4.Left + Form1.boule4.Width
    Form1.boule6.Top = Form1.boule5.Top + (Form1.boule5.Height - Form1.boule6.Height) \ 2
    Form1.boule6.Left = Form1.boule5.Left + Form1.boule5.Width
    Form1.boule7.Top = Form1.boule6.Top + (Form1.boule6.Height - Form1.boule7.Height) \ 2
    Form1.boule7.Left = Form1.boule6.Left + Form1.boule6.Width
    Form1.boule8.Top = Form1.boule7.Top + (Form1.boule7.Height - Form1.boule8.Height) \ 2
    Form1.boule8.Left = Form1.boule7.Left + Form1.boule7.Width
    Else
    Form1.tete.Left = 0
    End If
    Case 38: 'direction haut
    If Form1.tete.Top > 0 And Form1.tete.Top > vitesse Then
    Form1.tete.Picture = LoadPicture("C:\Smiley\Image\les personnage\le perso principal\smiley haut.gif")
    Form1.tete.Top = Form1.tete.Top - vitesse
    Form1.boule1.Left = Form1.tete.Left + (Form1.tete.Width - Form1.boule1.Width) \ 2
    Form1.boule1.Top = Form1.tete.Top + Form1.tete.Height
    Form1.boule2.Left = Form1.boule1.Left + (Form1.boule1.Width - Form1.boule2.Width) \ 2
    Form1.boule2.Top = Form1.boule1.Top + Form1.boule1.Height
    Form1.boule3.Left = Form1.boule2.Left + (Form1.boule2.Width - Form1.boule3.Width) \ 2
    Form1.boule3.Top = Form1.boule2.Top + Form1.boule2.Height
    Form1.boule4.Left = Form1.boule3.Left + (Form1.boule3.Width - Form1.boule4.Width) \ 2
    Form1.boule4.Top = Form1.boule3.Top + Form1.boule3.Height
    Form1.boule5.Left = Form1.boule4.Left + (Form1.boule4.Width - Form1.boule5.Width) \ 2
    Form1.boule5.Top = Form1.boule4.Top + Form1.boule4.Height
    Form1.boule6.Left = Form1.boule5.Left + (Form1.boule5.Width - Form1.boule6.Width) \ 2
    Form1.boule6.Top = Form1.boule5.Top + Form1.boule5.Height
    Form1.boule7.Left = Form1.boule6.Left + (Form1.boule6.Width - Form1.boule7.Width) \ 2
    Form1.boule7.Top = Form1.boule6.Top + Form1.boule6.Height
    Form1.boule8.Left = Form1.boule7.Left + (Form1.boule7.Width - Form1.boule8.Width) \ 2
    Form1.boule8.Top = Form1.boule7.Top + Form1.boule7.Height
    Else
    Form1.tete.Top = 0
    End If
    Case 39: 'direction droite
    If Form1.tete.Left + Form1.tete.Width < Screen.Width And Screen.Width - (Form1.tete.Left + Form1.tete.Width) > vitesse Then
    Form1.tete.Picture = LoadPicture("C:\Smiley\Image\les personnage\le perso principal\smiley droite.gif")
    Form1.tete.Left = Form1.tete.Left + vitesse
    Else
    Form1.tete.Left = Screen.Width - tete.Width
    End If
    Case 40: 'direction bas
    If Form1.tete.Top + Form1.tete.Height < Form1.StatusBar1.Top And Form1.tete.Top + Form1.tete.Height + vitesse < Form1.StatusBar1.Top Then
    Form1.tete.Picture = LoadPicture("C:\Smiley\Image\les personnage\le perso principal\smiley bas.gif")
    Form1.tete.Top = Form1.tete.Top + vitesse
    Else
    Form1.tete.Top = Form1.StatusBar1.Top - Form1.tete.Height
    End If
    End Select
    End Sub
    0