|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Bannato
Iscritto dal: Jan 2001
Città: Modena
Messaggi: 163
|
grafici con visual basic
Sapete come si fà a fare i grafici con visual basic? ci sono i riferimenti di excel, ma non so come fare, conoscete una guida? CIAO E GRAZIE!
|
![]() |
![]() |
![]() |
#2 |
Member
Iscritto dal: Oct 2002
Città: Magica ROMA!!!
Messaggi: 85
|
C'è il componente (OCX) MsChart.
Se scegli "Aggiungi componente" (o cliccando col tasto destro del mouse sulla barra dei componenti) ti apparira' la lista da cui selezionare MsChart. E poi è facile capirne il funzionamento. Ciao ![]() |
![]() |
![]() |
![]() |
#3 | |
Senior Member
Iscritto dal: Sep 2001
Città: Vicopisano (PI)
Messaggi: 11652
|
AIUTOOO!!!
Quote:
![]() Ho un problema con il componente MsChart!!! ![]() In pratica, voglio che visualizzi dei dati presi da un db. L'MSDN dice di utilizzare il controllo ADO ed ho provato prendendo il codice di esempio riportato. L'ho modificato secondo le mie esigenze (ho modificato la stringa SQL ed il percorso del db) ma IL PROMO RECORD CHE TROVA NON LO VISUALIZZA!!! ![]() ![]() ![]() ![]() ![]() HO istallato anche il SP5 di visual studio 6, ma non è servito a nulla! ![]() Ho fatto tantissimi tentativi, ma il risultato è sempre il solito!!! ![]() P.S: il codice è il seguente: ********************************************** Option Explicit ' Be sure to set a reference to the Microsoft ActiveX Data ' Objects 2.0 Library. Private rsProducts As New ADODB.Recordset Private cn As New ADODB.Connection Private Sub Form_Load() Dim strQuery As String ' SQL query string. ' First change the path to a valid path for your machine. cn.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _ "C:\db1.mdb" ' <-Change this path. ' Open the connection. cn.Open ' Create a query that retrieves only four fields. strQuery = "SELECT * FROM DATI" ' Open the recordset. rsProducts.Open strQuery, cn, adOpenKeyset ' Set the DataSource to the recordset. With MSChart1 .ShowLegend = True Set .DataSource = rsProducts End With End Sub ****************************************** la pag. dell'msdn alla quale ho fatto riferimento è questa: ********************************************** Data Binding the MSChart Control The Microsoft Chart control is a data bound control, and allows you to graphically represent numeric data. Unlike other data bound controls, however, the Chart control cannot be used with the Remote Data Control, or the Data control. It can be used with the ADO Data Control, an ADO Recordset, and the Data Environment. This example will show how to open an ADO Recordset that contains the fields you want to display, and set the Chart control's DataSource property to the Recordset object. If the first field contains string data, that data will be used as the X axis labels. The example below shows three series of data by first creating a Recordset object that has four fields; the first field contains the labels for the X axis, and remaining fields are displayed as series data. Option Explicit ' Be sure to set a reference to the Microsoft ActiveX Data ' Objects 2.0 Library. Private rsProducts As New ADODB.Recordset Private cn As New ADODB.Connection Private Sub Form_Load() Dim strQuery As String ' SQL query string. ' First change the path to a valid path for your machine. cn.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _ "C:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb" ' <-Change this path. ' Open the connection. cn.Open ' Create a query that retrieves only four fields. strQuery = "SELECT ProductName, UnitPrice, " & _ "UnitsInStock, UnitsOnOrder FROM Products WHERE SupplierID = 1" ' Open the recordset. rsProducts.Open strQuery, cn, adOpenKeyset ' Set the DataSource to the recordset. With MSChart1 .ShowLegend = True Set .DataSource = rsProducts End With End Sub ************************************************************* Grazie 1000 per l'aiuto! ![]() GHz! ![]()
__________________
>>PARTECIPA AI PROGETTI DI CALCOLO DISTRIBUITO CON BOINC.Italy!<<
You may say I'm a dreamer - But I'm not the only one - I hope someday you'll join us - And the team will be the 1# one BoincEmperor 1° Livello - Rotoloni DOCET!! Cactus rulez!! ![]() |
|
![]() |
![]() |
![]() |
#4 |
Member
Iscritto dal: Oct 2002
Città: Magica ROMA!!!
Messaggi: 85
|
Ciao ;-)
Grazie dei complimenti. NOn ho capito se il primo record non lo considera il controllo Ms Chart o se non te lo restituisce il Recordset. Cioè, se tu dopo aver aperto il recordset metti la riga seguente: MsgBox rsProducts.Fields("NomeCampo").Value ti restituisce il primo record? |
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Sep 2001
Città: Vicopisano (PI)
Messaggi: 11652
|
Innanzitutto grazie per l'aiuto!
![]() Dunque: ho inserito la riga di testo che mi hai scritto te, ovviamente inserendo al posto di "nomecampo" il valore del campo da visualizzare nell'msgbox. Funziona perfettamente: il valore è quello del primo record del recordret che però non è visualizzato dall'MsCHart. Com'è possibile? E' per caso un bug dell'OCX? Spero che tu abbia la soluzione a questo problema! Ciao e grazie! ![]() GHz! ![]()
__________________
>>PARTECIPA AI PROGETTI DI CALCOLO DISTRIBUITO CON BOINC.Italy!<<
You may say I'm a dreamer - But I'm not the only one - I hope someday you'll join us - And the team will be the 1# one BoincEmperor 1° Livello - Rotoloni DOCET!! Cactus rulez!! ![]() |
![]() |
![]() |
![]() |
#6 |
Member
Iscritto dal: Oct 2002
Città: Magica ROMA!!!
Messaggi: 85
|
Ciao ;-)
Prova cosi'... Apri il recordset in questo modo: Set rst = New Recordset rst.Open "select * from NomeTabella", cn, adOpenStatic, adLockOptimistic With MSChart1 Set .DataSource = rst .ShowLegend = True End With *************** Inoltre, apri la connessione in questo modo: cn.Open strConnessione ' qui metterai la tua stringa di connesione cn.CursorLocation = adUseClient 'metti il cursorlocation a client *************** Fammi sapere ;-)) |
![]() |
![]() |
![]() |
#7 |
Senior Member
Iscritto dal: Sep 2001
Città: Vicopisano (PI)
Messaggi: 11652
|
ciao shell, io ho provato così:
Codice:
Option Explicit ' Be sure to set a reference to the Microsoft ActiveX Data ' Objects 2.0 Library. Private rst As New ADODB.Recordset Private cn As New ADODB.Connection __________________________________________________________- Private Sub Form_Load() cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _ "C:\db1.mdb" ' qui metterai la tua stringa di connesione cn.CursorLocation = adUseNone 'metti il cursorlocation a client rst.Open "select minuto from dati", cn, adOpenStatic, adLockOptimistic ' Set the DataSource to the recordset. With MSChart1 .ShowLegend = True Set .DataSource = rst End With End Sub ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() NON E' POSSIBILEEE!!!! Ma succede anche a te questo problema con MsChart? Hai la possibilità di provare? Illuminami te ![]() ![]() Ciao e grazie infinite per l'aiuto! ![]() GHz
__________________
>>PARTECIPA AI PROGETTI DI CALCOLO DISTRIBUITO CON BOINC.Italy!<<
You may say I'm a dreamer - But I'm not the only one - I hope someday you'll join us - And the team will be the 1# one BoincEmperor 1° Livello - Rotoloni DOCET!! Cactus rulez!! ![]() |
![]() |
![]() |
![]() |
#8 |
Member
Iscritto dal: Oct 2002
Città: Magica ROMA!!!
Messaggi: 85
|
a me non è mai successo.
Cmq perchè hai messo adUseNone? |
![]() |
![]() |
![]() |
#9 | |
Senior Member
Iscritto dal: Sep 2001
Città: Vicopisano (PI)
Messaggi: 11652
|
Quote:
Cmq forse è un problema del db....anche se ne dibito fortemente....ho preso il Biblio.mdb e l'ho modificato con il VisData....non ho acces 97... Proverò su un'altro pc....che devo fa....poi ti faccio sapere! ![]() Grazie 1000! Ciao, Ghz! ![]()
__________________
>>PARTECIPA AI PROGETTI DI CALCOLO DISTRIBUITO CON BOINC.Italy!<<
You may say I'm a dreamer - But I'm not the only one - I hope someday you'll join us - And the team will be the 1# one BoincEmperor 1° Livello - Rotoloni DOCET!! Cactus rulez!! ![]() |
|
![]() |
![]() |
![]() |
#10 |
Member
Iscritto dal: Oct 2002
Città: Magica ROMA!!!
Messaggi: 85
|
Fammi sapere come andrà usando un altro Database.
Ciao ![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Iscritto dal: Sep 2001
Città: Vicopisano (PI)
Messaggi: 11652
|
Ciao shell32!!!
FINALMENTE, dopo giorni di scervellamento, dopo aver girato per i server di tutto il pianeta, sono riuscito, tramite il consiglio di uno su un'altro forum, a far funzionare il controllo come si deve. ![]() Era una cavolata, ma evidentemente non ci avevi pensato. ![]() E' bastato fare un recordset.movefirst prima di passare i dati al grafico! ![]() Ora vengono visualizzati tutti i dati presenti nel recordset correttamente! ![]() Cmq come c'è bisogno di fare il movefirst per farlo funzionare? Non me lo so spiegare..... ![]() Ciao, GHz! ![]()
__________________
>>PARTECIPA AI PROGETTI DI CALCOLO DISTRIBUITO CON BOINC.Italy!<<
You may say I'm a dreamer - But I'm not the only one - I hope someday you'll join us - And the team will be the 1# one BoincEmperor 1° Livello - Rotoloni DOCET!! Cactus rulez!! ![]() |
![]() |
![]() |
![]() |
#12 |
Member
Iscritto dal: Oct 2002
Città: Magica ROMA!!!
Messaggi: 85
|
sono contento che tu abbia risolto
![]() Cmq, a me funzionava senza fare il movefirst. Spesso bisogna fare un .movelast e un .movefirst per fare una specie di refresh al recordset ed essere sicuri del popolamento. Vabbe', l'importante è che tu abbia risolto ;-) Ciao |
![]() |
![]() |
![]() |
#13 | |
Senior Member
Iscritto dal: Sep 2001
Città: Vicopisano (PI)
Messaggi: 11652
|
Quote:
![]() Grazie shell! ![]() Ciao, GHz! ![]()
__________________
>>PARTECIPA AI PROGETTI DI CALCOLO DISTRIBUITO CON BOINC.Italy!<<
You may say I'm a dreamer - But I'm not the only one - I hope someday you'll join us - And the team will be the 1# one BoincEmperor 1° Livello - Rotoloni DOCET!! Cactus rulez!! ![]() |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 01:56.