Subject |
Re: String question |
From |
Akshat Kapoor <akshat.kapoor@kapoorsons.in> |
Date |
Wed, 15 Nov 2023 22:24:37 +0530 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
my_table.dbf, form_numb.wfm |
Good Evening Charlie,
> Thanks very much for the suggestion. I guess I don't get how this will help as the result seems to delete the commas and is numeric. I am looking for something that will add the commas and the result stays character string.
>
>> function Text2Num
>> /*
>> -------------------------------------------------------------
>> Programmer..: Akshat Kapoor
>> Date........: August, 2021
I simply do not remember why I wrote this.
Sorry for the late reply. These days my dbase hours are very limited.
With diwali festival (Biggest festival of the year in northern India)
and some family functions going back to back I gave myself more time
than I should have given.
A QUICK AND DIRTY way of demonstrating what you may want to do.
Hope this helps.
Simply copy the files and run the form. It lacks close buttons so you
will probably be requiring the red cross button of the form.
The underlying data is not changed. You will be able to change the
formatting at will as I have used transform. The key is beforeGetValue
event.
Regards
Akshat
| ** END HEADER -- do not remove this line
//
// Generated on 15-11-2023
//
parameter bModal
local f
f = new form_numbForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class form_numbForm of FORM
with (this)
height = 21.0455
left = 35.1429
top = 0.0
width = 94.2857
text = ""
endwith
this.TABLE1 = new QUERY(this)
with (this.TABLE1)
left = 83.0
top = 14.0
width = 4.0
height = 1.0
sql = "select my_numb,my_numb*1 as my_numb2 from my_table"
active = true
endwith
with (this.TABLE1.rowset)
with (fields["my_numb2"])
beforeGetValue = {||transform(this.value,'99,99,99,999.99')}
endwith
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.table1.rowset
columns["Column1"] = new GRIDCOLUMN(form.GRID1)
with (columns["Column1"])
dataLink = form.table1.rowset.fields["my_numb"]
editorType = 3 // SpinBox
width = 17.1429
endwith
columns["Column2"] = new GRIDCOLUMN(form.GRID1)
with (columns["Column2"])
dataLink = form.table1.rowset.fields["my_numb2"]
editorType = 1 // EntryField
width = 28.5714
endwith
with (columns["Column1"].editorControl)
rangeMax = 100
rangeMin = 1
endwith
with (columns["Column1"].headingControl)
value = "my_numb"
endwith
with (columns["Column2"].editorControl)
function = "@J"
endwith
with (columns["Column2"].headingControl)
value = "my_numb2"
endwith
height = 12.5
left = 5.0
top = 2.5
width = 57.0
endwith
this.rowset = this.table1.rowset
function my_numb2_beforeGetValue()
return transform(this.value,'99,99,99,999.99')
endclass
|
|