Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a calculations in a separate field

Status
Not open for further replies.

ridifvx

Programmer
Apr 10, 2003
34
ID
well i'm new in VFP version 8 (3 weeks) i am migrating from VB :)
and now i have problem (rookie problems)

i made a form with a 'mark' database. one of this field is related with the other two fields...i have three fields :)
1. credits (a numeric) display in txtsks
2. marks (a character A,B,C,D,..and so on)..display in txtnilai
3. Point = credits*marks display in txtpoint

where A = 4,B = 3,C=2 and D =1 and so on

i have made this code and it's seem not working

DO CASE
CASE thisform.pageframe1.page1.txtNilai.Value = 'A'
? thisform.pageframe1.page1.txtPoint.Value = 4 * thisform.pageframe1.page1.txtSks.Value
CASE thisform.pageframe1.page1.txtNilai.Value = 'B'
? thisform.pageframe1.page1.txtPoint.Value = 3 * thisform.pageframe1.page1.txtSks.Value
CASE thisform.pageframe1.page1.txtNilai.Value = 'C'
? thisform.pageframe1.page1.txtPoint.Value = 2 * thisform.pageframe1.page1.txtSks.Value
CASE thisform.pageframe1.page1.txtNilai.Value = 'D'
?thisform.pageframe1.page1.txtPoint.Value=
thisform.pageframe1.page1.txtSks.Value
OTHERWISE
? thisform.pageframe1.page1.txtPoint.Value = 0
ENDCASE

of course is not homeworks Bro.. :)
sorry 4 bad english
and thanks in advance
 
If you want to display a value:
? myvalue * 4

If you want to store the calculated value into another field:
newvalue = myvalue * 4

You seem to be attempting to do both in the same statement:
? newvalue = myvalue * 4

This is valid FoxPro syntax, but won't give you what you want. It will display .T. or .F. depending on whether newvalue equals myvalue times 4.

Jim
 
HI

1. Where have you put the code.. in which event ?

DO CASE
CASE thisform.pageframe1.page1.txtNilai.Value = 'A'
? thisform.pageframe1.page1.txtPoint.Value = 4 * thisform.pageframe1.page1.txtSks.Value
CASE thisform.pageframe1.page1.txtNilai.Value = 'B'
? thisform.pageframe1.page1.txtPoint.Value = 3 * thisform.pageframe1.page1.txtSks.Value
CASE thisform.pageframe1.page1.txtNilai.Value = 'C'
? thisform.pageframe1.page1.txtPoint.Value = 2 * thisform.pageframe1.page1.txtSks.Value
CASE thisform.pageframe1.page1.txtNilai.Value = 'D'
?thisform.pageframe1.page1.txtPoint.Value=
thisform.pageframe1.page1.txtSks.Value
OTHERWISE
? thisform.pageframe1.page1.txtPoint.Value = 0
ENDCASE

If you have kept this code in the Refresh() event of the third field textbox, it should work. And you should call this refresh() event, every time you change the values in the first two textboxes.

2. If you have a table with all these three fields, why dont you update the third field with correct vales calculated? But if that is always a calculated value, there is no need for this field at all.

3. The second field nilai or whatever, why should not you keep that as Integer type, since you seem to have only digits in that. Why should you keep that as character based ?.

:)

ramani :)
(Subramanian.G)
 
Thanks Ramani..u help so much

Btw
1. I put the events in lostfocus events on txtsks, just think that a user which insert this field(txtsks) had already to insert a txtnilai first..but it seem not work
ok i will put it in refresh() events :)
2&3 yeah u absolutely right but i have to use this field in order to make a usual reports for students (u know it that we got mark in a,b,c or D)

ThaNKS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top