Jump to content

[help] ListView can not get/fill data


nightbb
 Share

Recommended Posts

hi all i would like to ask all of you

i want create a little program which get data from yahoo finance

i want use listview to display the data which i have define

but i do not know why not work

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <IE.au3>
#include <Array.au3>
#include <String.au3>

$Form1 = GUICreate("My Yahoo Stock", 500, 268)
$ListView1 = GUICtrlCreateListView("Last Price|Bid|Ask|Bid Volume|Ask Volume|Volume|Day Hi| Day Low|", 8, 8, 500, 249)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)


; use IE to get data from yahoo finance
$oHTTP = _IECreate("http://download.finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&s=01398.hk", 0, 0, 1, 0)
$sText = _IEBodyReadText ($oHTTP)


;use StringSplit() to split with ","
$avarray = StringSplit($sText, ",", 3)


 For $i = 0 To UBound($avarray) + 1
   
  ; fill data into listview
    GUICtrlCreateListViewItem($i[0] & "|" & $i[1] & "|"& $i[2]& "|"& $i[3] &"|"& $i[4] &"|" & $i[5] & "|" & $i[6] & "|" & $i[7],$ListView1)
      
   Next

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
  
EndSwitch
WEnd

this is the error:

C:\Documents and Settings\Administrator\??\listv.au3 (19) : ==> Subscript used with non-Array variable.:

GUICtrlCreateListViewItem($i[0] & "|" & $i[1] & "|"& $i[2]& "|"& $i[3] &"|"& $i[4] &"|" & $i[5] & "|" & $i[6] & "|" & $i[7],$ListView1)

GUICtrlCreateListViewItem($i^ ERROR

->19:54:14 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 4.221

any one can slove it ?

or is there anyother better way to do this?

many thanks

Edited by nightbb
Link to comment
Share on other sites

hi all i would like to ask all of you

i want create a little program which get data from yahoo finance

i want use listview to display the data which i have define

but i do not know why not work

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <IE.au3>
#include <Array.au3>
#include <String.au3>

$Form1 = GUICreate("My Yahoo Stock", 500, 268)
$ListView1 = GUICtrlCreateListView("Last Price|Bid|Ask|Bid Volume|Ask Volume|Volume|Day Hi| Day Low|", 8, 8, 500, 249)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)


; use IE to get data from yahoo finance
$oHTTP = _IECreate("http://download.finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&s=01398.hk", 0, 0, 1, 0)
$sText = _IEBodyReadText ($oHTTP)


;use StringSplit() to split with ","
$avarray = StringSplit($sText, ",", 3)


 For $i = 0 To UBound($avarray) + 1
   
; fill data into listview
    GUICtrlCreateListViewItem($i[0] & "|" & $i[1] & "|"& $i[2]& "|"& $i[3] &"|"& $i[4] &"|" & $i[5] & "|" & $i[6] & "|" & $i[7],$ListView1)
      
   Next

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
  
EndSwitch
WEnd

this is the error:

C:\Documents and Settings\Administrator\??\listv.au3 (19) : ==> Subscript used with non-Array variable.:

GUICtrlCreateListViewItem($i[0] & "|" & $i[1] & "|"& $i[2]& "|"& $i[3] &"|"& $i[4] &"|" & $i[5] & "|" & $i[6] & "|" & $i[7],$ListView1)

GUICtrlCreateListViewItem($i^ ERROR

->19:54:14 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 4.221

any one can slove it ?

or is there anyother better way to do this?

many thanks

$i isn't array. Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <IE.au3>
#include <Array.au3>
#include <String.au3>

$Form1 = GUICreate("My Yahoo Stock", 500, 268)
$ListView1 = GUICtrlCreateListView("Last Price|Bid|Ask|Bid Volume|Ask Volume|Volume|Day Hi| Day Low|", 8, 8, 500, 249)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)


; use IE to get data from yahoo finance
$oHTTP = _IECreate("http://download.finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&s=01398.hk", 0, 0, 1, 0)
$sText = _IEBodyReadText ($oHTTP)


;use StringSplit() to split with ","
$array = StringSplit($sText, ",", 3)


For $i = 0 To UBound($array) + 1
   
; fill data into listview
    GUICtrlCreateListViewItem($array[0] & "|" & $array[1] & "|"& $array[2]& "|"& $array[3] &"|"& $array[4] &"|" & $array[5] & "|" & $array[6] & "|" & $array[7],$ListView1)
      
   Next

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
  
EndSwitch
WEnd

you mean should be replace with like this ?

GUICtrlCreateListViewItem($array[0] & "|" & $array[1] & "|"& $array[2]& "|"& $array[3] &"|"& $array[4] &"|" & $array[5] & "|" & $array[6] & "|" & $array[7],$ListView1)

still not work

or am i use wrong concept ?

Edited by nightbb
Link to comment
Share on other sites

Maybe this:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <IE.au3>
#include <Array.au3>
#include <String.au3>

$Form1 = GUICreate("My Yahoo Stock", 500, 268)
$ListView1 = GUICtrlCreateListView("Last Price|Bid|Ask|Bid Volume|Ask Volume|Volume|Day Hi| Day Low|", 8, 8, 500, 249)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)


; use IE to get data from yahoo finance
$oHTTP = _IECreate("http://download.finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&s=01398.hk", 0, 0, 1, 0)
$sText = _IEBodyReadText ($oHTTP)

;use StringSplit() to split with ","
$array = StringSplit($sText, ",")

$DATA = ""
For $i = 1 To $array[0]
  $DATA &= $array[$i] & "|"
Next
GUICtrlCreateListViewItem($DATA,$ListView1)

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
  
EndSwitch
WEnd
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...