création d'histogramme en vb - VB/VBA/VBS - Programmation
Marsh Posté le 24-06-2002 à 14:26:04
je sais qu'il existe un contrôle ocx, il te suffit d'aller dans les options de vb, et ajour de composant ! tu trouveras le contrôle qui te permet d'avoir les histogrammes... 
 
 
essaye d'aller sur www.vbfrance.com, il y a des choses interressantes...
Marsh Posté le 24-06-2002 à 14:33:25
je comprends pas  
j'ai jamais fait de vb de ma vie et je dois faire ca pour demain
Marsh Posté le 24-06-2002 à 14:34:51
en fait je voudrais que dès qu'il y a ne insertion de valeur le graphique soit automatiquement fait
Marsh Posté le 24-06-2002 à 15:17:53
tu connais pas d'autre langage que vb ? car je ne sais pas, mais ca va être un peu court de construire quelques chose en quelques heures, surtout que je n'ai jamais fait ce que tu veux.. 
 
sinon, tu fait projet --> composant tu arrive une liste avec tous les composant, parmi eux normalement si tous va bien, tu as le composant qui te permet de faire des histoigrammes. Dés que tu clique sur chacun d'entre eux ,tu vois l'objet apparaître sur la barre des taches...à gauche !  
 
 
aprés pour le code, je ne le connais pas, mais un conseil, cherche sur internet, sur www.vbfrance.com, www.vbsource.com, www.google.fr, ect. Tu y trouveras surrement la solution, car je ne veux pas paraître pessimiste mais quelques heures c'est trop court !
Marsh Posté le 24-06-2002 à 15:45:26
VERSION 5.00 
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX" 
Begin VB.Form Frequency  
   Caption         =   "Frequency Distribution" 
   ClientHeight    =   5175 
   ClientLeft      =   6120 
   ClientTop       =   5625 
   ClientWidth     =   5610 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   5175 
   ScaleWidth      =   5610 
   Begin MSComDlg.CommonDialog CommonDialog1  
      Left            =   2640 
      Top             =   240 
      _ExtentX        =   847 
      _ExtentY        =   847 
      _Version        =   327681 
   End 
   Begin VB.CommandButton File  
      Caption         =   "Select Database File" 
      Height          =   375 
      Left            =   120 
      TabIndex        =   4 
      Top             =   360 
      Width           =   2415 
   End 
   Begin VB.CommandButton Back  
      Caption         =   "Back " 
      Height          =   375 
      Left            =   3240 
      TabIndex        =   3 
      Top             =   4320 
      Width           =   1815 
   End 
   Begin VB.CommandButton Show  
      Caption         =   "Show it!" 
      Height          =   375 
      Left            =   360 
      TabIndex        =   2 
      Top             =   4320 
      Width           =   1695 
   End 
   Begin VB.ListBox field_list  
      Height          =   2985 
      Left            =   2880 
      TabIndex        =   1 
      Top             =   960 
      Width           =   2535 
   End 
   Begin VB.ListBox table_list  
      Height          =   2985 
      Left            =   120 
      TabIndex        =   0 
      Top             =   960 
      Width           =   2415 
   End 
End 
Attribute VB_Name = "Frequency" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Public dbMydb As Database 
Public recMyRec As Recordset 
Public sMyField As String 
 
Private Sub Back_Click() 
MsgBox "TO BE IMPLEMENTED LATER, WHEN THERE ARE MANY FUNCTIONS." 
End Sub 
 
Private Sub field_list_Click() 
    sMyField = field_list.Text 
End Sub 
 
Private Sub File_Click() 
    Dim sFile As String 
    With CommonDialog1 
        'To Do 
        'set the flags and attributes of the 
        'common dialog control 
        .Filter = "Access Files (*.mdb)|*.mdb" 
        .ShowOpen 
        If Len(.filename) = 0 Then 
            Exit Sub 
        End If 
        sFile = .filename 
    End With 
     
    Dim nCount As Integer 
    Dim sTemp As String 
     
    Set dbMydb = OpenDatabase(sFile) 
    nCount = 0 
    table_list.Clear 
    While nCount < dbMydb.TableDefs.Count 
        sTemp = dbMydb.TableDefs(nCount).Name 
        If Not sTemp Like "MSys*" Then 
            table_list.AddItem dbMydb.TableDefs(nCount).Name 
        End If 
            nCount = nCount + 1 
    Wend 
    For nCount = 0 To dbMydb.TableDefs.Count - 1 
        Debug.Print table_list.List(nCount) 
    Next 
     
End Sub 
 
Private Sub Form_Load() 
    Set recMyRec = Nothing 
End Sub 
 
Private Sub Show_Click() 
    If sMyField Like "" Then 
        MsgBox "You must select a field." 
        Exit Sub 
    End If 
    If recMyRec.Fields.Count = 0 Then 
        MsgBox "the Table is empty!" 
        Exit Sub 
    End If 
     
     
    If recMyRec.Fields(sMyField).Type = dbBigInt Or _ 
        recMyRec.Fields(sMyField).Type = dbDecimal Or _ 
        recMyRec.Fields(sMyField).Type = dbDouble Or _ 
        recMyRec.Fields(sMyField).Type = dbDouble Or _ 
        recMyRec.Fields(sMyField).Type = dbInteger Or _ 
        recMyRec.Fields(sMyField).Type = dbLong Or _ 
        recMyRec.Fields(sMyField).Type = dbNumeric Then 
         
    Else 
        MsgBox "This field does not have a valid data type to be plotted." 
        Exit Sub 
    End If 
    Dim plot As New FrmPlot 
    Set plot.recMy = dbMydb.OpenRecordset(table_list.Text) 
    plot.Show 
     
End Sub 
 
Private Sub table_list_Click() 
    Dim nCount As Integer 
    nCount = 0 
    Set recMyRec = dbMydb.OpenRecordset(table_list.Text) 
    field_list.Clear 
    While nCount < recMyRec.Fields.Count 
        field_list.AddItem recMyRec.Fields(nCount).Name 
        nCount = nCount + 1 
    Wend 
End Sub 
 
j'ai trouvé ca mais je ne sais pas comment le mettre en forme  
peux tu me dire s'il marche et m'envoyer le fichier excel après je te serais entièrement reconnaissant
Marsh Posté le 24-06-2002 à 17:34:14
je n'ai jamais fait du VBA, seulement des programmes compilés en Vb...Si tu veux le déboguer tu le mets sur une feuille vierge et tu suis les instructions de débogage, il va te le dire...tu as déjà des choses qui me paraissent curieuse : 
 
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"  
Begin VB.Form Frequency   
  Caption         =   "Frequency Distribution"  
  ClientHeight    =   5175  
  ClientLeft      =   6120  
  ClientTop       =   5625  
  ClientWidth     =   5610  
  LinkTopic       =   "Form1"  
  ScaleHeight     =   5175  
  ScaleWidth      =   5610  
  Begin MSComDlg.CommonDialog CommonDialog1   
     Left            =   2640  
     Top             =   240  
     _ExtentX        =   847  
     _ExtentY        =   847  
     _Version        =   327681  
  End  
  Begin VB.CommandButton File   
     Caption         =   "Select Database File"  
     Height          =   375  
     Left            =   120  
     TabIndex        =   4  
     Top             =   360  
     Width           =   2415  
  End  
  Begin VB.CommandButton Back   
     Caption         =   "Back "  
     Height          =   375  
     Left            =   3240  
     TabIndex        =   3  
     Top             =   4320  
     Width           =   1815  
  End  
  Begin VB.CommandButton Show   
     Caption         =   "Show it!"  
     Height          =   375  
     Left            =   360  
     TabIndex        =   2  
     Top             =   4320  
     Width           =   1695  
  End  
  Begin VB.ListBox field_list   
     Height          =   2985  
     Left            =   2880  
     TabIndex        =   1  
     Top             =   960  
     Width           =   2535  
  End  
  Begin VB.ListBox table_list   
     Height          =   2985  
     Left            =   120  
     TabIndex        =   0  
     Top             =   960  
     Width           =   2415  
  End  
End  
 
toutes ces partis ne sont pas mis dans des fonctions ou procédure, ce n'ets pas normal...ensuite : qu'est ce que vient faire cette clé :  
 
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"  
 
elle appartient à la base de registre, c'est l'enregistrement, dans les BDR... 
 
 
ensuite, tu as ceci qui me parait aussi curieux, ca ressemble à des fichiers dépendance : 
 
Attribute VB_Name = "Frequency"  
Attribute VB_GlobalNameSpace = False  
Attribute VB_Creatable = False  
Attribute VB_PredeclaredId = True  
Attribute VB_Exposed = False  
 
ceci sont des variables, que tu devra mettre dans des modules : 
 
Public dbMydb As Database  
Public recMyRec As Recordset  
Public sMyField As String  
 
le reste ce sont des prcédures normal, asscociès à des objets divers : 
 
Private Sub Back_Click()  
MsgBox "TO BE IMPLEMENTED LATER, WHEN THERE ARE MANY FUNCTIONS."  
End Sub  
 
Private Sub field_list_Click()  
   sMyField = field_list.Text  
End Sub  
 
Private Sub File_Click()  
   Dim sFile As String  
   With CommonDialog1  
       'To Do  
       'set the flags and attributes of the  
       'common dialog control  
       .Filter = "Access Files (*.mdb)|*.mdb"  
       .ShowOpen  
       If Len(.filename) = 0 Then  
           Exit Sub  
       End If  
       sFile = .filename  
   End With  
     
   Dim nCount As Integer  
   Dim sTemp As String  
     
   Set dbMydb = OpenDatabase(sFile)  
   nCount = 0  
   table_list.Clear  
   While nCount < dbMydb.TableDefs.Count  
       sTemp = dbMydb.TableDefs(nCount).Name  
       If Not sTemp Like "MSys*" Then  
           table_list.AddItem dbMydb.TableDefs(nCount).Name  
       End If  
           nCount = nCount + 1  
   Wend  
   For nCount = 0 To dbMydb.TableDefs.Count - 1  
       Debug.Print table_list.List(nCount)  
   Next  
     
End Sub  
Private Sub Form_Load()  
   Set recMyRec = Nothing  
End Sub  
 
Private Sub Show_Click()  
   If sMyField Like "" Then  
       MsgBox "You must select a field."  
       Exit Sub  
   End If  
   If recMyRec.Fields.Count = 0 Then  
       MsgBox "the Table is empty!"  
       Exit Sub  
   End If  
     
     
   If recMyRec.Fields(sMyField).Type = dbBigInt Or _  
       recMyRec.Fields(sMyField).Type = dbDecimal Or _  
       recMyRec.Fields(sMyField).Type = dbDouble Or _  
       recMyRec.Fields(sMyField).Type = dbDouble Or _  
       recMyRec.Fields(sMyField).Type = dbInteger Or _  
       recMyRec.Fields(sMyField).Type = dbLong Or _  
       recMyRec.Fields(sMyField).Type = dbNumeric Then  
         
   Else  
       MsgBox "This field does not have a valid data type to be plotted."  
       Exit Sub  
   End If  
   Dim plot As New FrmPlot  
   Set plot.recMy = dbMydb.OpenRecordset(table_list.Text)  
   plot.Show  
     
End Sub  
 
Private Sub table_list_Click()  
   Dim nCount As Integer  
   nCount = 0  
   Set recMyRec = dbMydb.OpenRecordset(table_list.Text)  
   field_list.Clear  
   While nCount < recMyRec.Fields.Count  
       field_list.AddItem recMyRec.Fields(nCount).Name  
       nCount = nCount + 1  
   Wend  
End Sub 
Marsh Posté le 24-06-2002 à 14:01:43
bonjour
pouvez vous me donner les quelques lignes de code pour créer un histogramme en vb à partir de valeurs insérées auparavant dans des cellules du tableur
merci d'avance