Program:
Object formulario as Form
BorderStyle=2
center
Height=300
Width=800
caption="M?dia semal e mensal das An?lises"
Object grupo as groupbox
height=100
top=10
left=10
Caption="Semana"
Object combo as ComboBox
Top=15
left=5
AddItem("Segunda-Feira")
AddItem("Ter?a-Feira")
AddItem("Quarta-Feira")
AddItem("Quinta-Feira")
AddItem("Sexta-Feira")
End Object
Object btn1 as Button
caption="Selecionar"
left=30
top=50
OnClick=calcular
End Object
End Object
Object grupo1 as groupbox
height=100
Top=120
Left=10
Caption="N? Pacientes"
Object combo1 as ComboBox
Top=15
Left=5
AddItem("1")
AddItem("2")
AddItem("3")
AddItem("4")
AddItem("5")
AddItem("6")
AddItem("7")
AddItem("8")
AddItem("9")
AddItem("10")
End Object
Object btn3 as Button
caption="Selecionar"
left=30
top=50
OnClick=calcular1
End Object
End Object
Object grupo2 as groupBox
left=200
Top=10
Height=210
Caption="Resultado"
Object lstbx as ListBox
Left=10
Top=15
Height=140
Width=90
End Object
Object lstbx1 as ListBox
Left=110
Top=15
Height=140
Width=70
End Object
Object btn2 as Button
caption="Apagar"
left=100
top=170
OnClick=apagar
End Object
Object btn4 as Button
caption="Salvar"
left=10
top=170
End Object
End Object
Object stst as StatusBar
SimplePanel=True
End Object
showmodal
End Object
Sub calcular(s as Button)
dim str as String
str=combo.item(combo.itemindex)
lstbx.AddItem(str+" --> ")
lstbx.AddItem("")
End Sub
Sub calcular1(s as Button)
Dim str1 as String
str1=combo1.item(combo1.itemindex)
lstbx1.AddItem(str1)
lstbx1.AddItem("")
End Sub
Sub apagar(s as Button)
lstbx.Clear
lstbx1.Clear
End Sub
I need to pic the values of the second listbox and make a sum of all values and then make a division with the amount of days selected in the first listbox and finally show the result in the StatusBar, helppp
And need direction on how to save to .txt file the content of the two listbox?s.
Thanks :D
media calculation
m?dia calculation
Hey Admin can you help me?
Thanks. :D
Thanks. :D
m?dia calculation
sorry did not see your mail.
get all values of the list box and sum them
dim c as integer
dim total as double
total=0
for c= 0 to secondlistbox.itemcount-1
total=total+val(secondlistbox.item(c))
next c
``check if zero
if firstlistbox.itemindex>-1 then
total=total/val(firstlistbox.item(firstlistbox.itemindex))
else
shomessage "no days selected"
end if
`show in statusbar
statusbar.simpletext=str$(total)
that was the first question
now the second|:
dim file as filestream
dim c as integer
if fileexists("filestream.txt")=true then kill "filestream.txt"
file.open("filestream.txt")
file.position=0
for c=0 to listbox1.itemcount-1
file.write(listbox1.item(c)+chr$(13))
next c
file.close
if fileexists("filestream2.txt")=true then kill "filestream2.txt"
file.open("filestream2.txt")
file.position=0
for c=0 to listbox2.itemcount-1
file.write(listbox2.item(c)+chr$(13))
next c
file.close
i did not tested the code but should work
best regards
get all values of the list box and sum them
dim c as integer
dim total as double
total=0
for c= 0 to secondlistbox.itemcount-1
total=total+val(secondlistbox.item(c))
next c
``check if zero
if firstlistbox.itemindex>-1 then
total=total/val(firstlistbox.item(firstlistbox.itemindex))
else
shomessage "no days selected"
end if
`show in statusbar
statusbar.simpletext=str$(total)
that was the first question
now the second|:
dim file as filestream
dim c as integer
if fileexists("filestream.txt")=true then kill "filestream.txt"
file.open("filestream.txt")
file.position=0
for c=0 to listbox1.itemcount-1
file.write(listbox1.item(c)+chr$(13))
next c
file.close
if fileexists("filestream2.txt")=true then kill "filestream2.txt"
file.open("filestream2.txt")
file.position=0
for c=0 to listbox2.itemcount-1
file.write(listbox2.item(c)+chr$(13))
next c
file.close
i did not tested the code but should work
best regards
m?dia calculation
Thank you Admin, i?ll tell you the result later. :P