Re: [Gambas-user] Currency and addition/subtraction

2010-03-12 Thread charlesg

Hi,

I guess the simple answer is:
fTotal += Val(tblView[row, column].text)
However, you will eventually run into rounding errors.

there was quite a lengthy thread not long ago about this. The conclusion (if
such a thing can be reached on a forum :-)) was that currency should be
worked on as integers and decimal points added at display time. The problem
is compounded by barmy tax authorities on the continent who demand
calculations to four decimals.

At the time, I wrote the following simply as a test. As with most of my
programming, it is unlikely to be the most efficient method. :blush:



 PUBLIC SUB btnRun_Click()
 DIM iInt AS Integer
 DIM j AS Integer
 
 IF InStr(txtInput.text, .) = 0 THEN 'no decimal entered ie assume in
 cents
   TRY iInt = Val(txtInput.text)
   IF ERROR THEN 
 PRINT trapped 'do someting if it is not a number
   ENDIF 
 ELSE 
   iInt = Val(txtInput.text) * 10 ^ Val(txtDecPlaces.text) + 0.5 'multiply
 out
 ENDIF 
 
 txtInteger.text = Str(iInt) 'display integer representation
 
 IF Len(txtInteger.text)  Val(txtDecPlaces.text) THEN 'if the integer
 equivalent is long enough to accomodate the required dec places
   lblOutput.text = Str(Left(txtInteger.text, Len(txtInteger.text) -
 Val(txtDecPlaces.text)))  .  Str(Right(txtInteger.text,
 Val(txtDecPlaces.text)))
 ELSE 'pad out with leading zeroes
   lblOutput.text = Str(txtInteger.text) 
   FOR j = Len(txtInteger.text) TO Val(txtDecPlaces.text) - 1
 lblOutput.text = 0  lblOutput.Text
   NEXT 
   lblOutput.text = 0.  lblOutput.text
 ENDIF 
 END 
 

rgds
-- 
View this message in context: 
http://old.nabble.com/Currency-and-addition-subtraction-tp27872220p27874102.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Currency and addition/subtraction

2010-03-12 Thread Les Hardy
Keith Clark wrote:
 I have a TableView object and have imported some data into it that is
 formatted as currency.  How can I know take that and add it to a Float
 variable?

 Keith



   
dim cur as string = £
dim floatvar as float

floatvar = Val(Replace(TableView1[TableView1.row, 1].Text, cur, ))


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] TableView.text conversion

2010-03-12 Thread Keith Clark
I have input a value into a TableView cell, and now I want to read it.
The problem is that I want to read it as a text string.  The 'number' is
actually an ISBN code.  It can sometimes be a string, as it can contain
an 'X' or a 10 digit number, but starting with a 0.

For example, 0123456789, 1234567891, and 012345678X are all valid values
for the cell.

So, when the cell value is say 0123456789 and I convert it with str$, I
get 123456789, the zero is dropped.  Is there an easy way around this or
do I have to check the leading character each time for a '0'?

Thanks,

Keith



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] TableView.text conversion

2010-03-12 Thread Les Hardy
Keith Clark wrote:
 I have input a value into a TableView cell, and now I want to read it.
 The problem is that I want to read it as a text string.  The 'number' is
 actually an ISBN code.  It can sometimes be a string, as it can contain
 an 'X' or a 10 digit number, but starting with a 0.

 For example, 0123456789, 1234567891, and 012345678X are all valid values
 for the cell.

 So, when the cell value is say 0123456789 and I convert it with str$, I
 get 123456789, the zero is dropped.  Is there an easy way around this or
 do I have to check the leading character each time for a '0'?

 Thanks,

 Keith

   
Hi Keith, Since Jan 2007 ISBN numbers have been 13 digits and should 
consist of 5 parts with each section being separated by spaces or hyphens.
Because of this, your ISBN numbers will always be stored and displayed 
as strings.
There is no conversion needed.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] Using a printer documentation

2010-03-12 Thread Keith Clark
Could someone forward me a few links about how to use a printer from
within Gambas?  I need to know how to Print to a system default
printer.

Thanks

Keith



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] LostFocus() not working on ubuntu !

2010-03-12 Thread Vassilis K
the (textbox) LostFocus() routine is working on Opensuse (with Gambas
2.17) but not on Ubuntu (with Gambas 2.19)!
The same components of Gambas are loaded on both PCs!
gb, gb.db, gb.db.form, gb.form, gb.image, gb.net, gb.qt, gb.qt.ext,
gb.vb.


PUBLIC SUB tEponimia_LostFocus()
  DIM rs33 AS Result
  DIM i AS Integer
  DIM htable AS Table
  DIM Diktis AS Integer
  
  ListBox1.Clear
  MODMain.Connect()
  IF db.Tables.Exist(Aplianikis) THEN 
rs33 = MODMain.$Con.exec(select DISTINCT Eponimia from Aplianikis
where Eponimia LIKE '  tEponimia.Text  %')
TRY PRINT rs33!Eponimia
IF ERROR THEN 
'ListBox1.Add()
'ListBox1.Clear
'tEponimia.Clear
'tEponimia.SetFocus
ELSE 
  FOR EACH rs33
 ListBox1.Add(rs33!Eponimia)
  NEXT  
ENDIF 
  ELSE 
MODMain.Connect()
  htable = db.Tables.Add(Aplianikis)
  htable.Fields.Add(aa, db.Serial, 10)
  htable.Fields.Add(Eponimia, db.String, 40)
  htable.Fields.Add(AFM, db.String, 18)
  htable.Fields.Add(Hmerominia, db.Date)
  htable.Fields.Add(Poson, db.Float)
  htable.Fields.Add(Checkbox, gb.Boolean,, FALSE)
  htable.PrimaryKey = [aa]
  htable.Update
  ENDIF   
END




--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Using a printer documentation

2010-03-12 Thread Johny Provoost
You could look in the help under gb.qt.ext and deeper down on Draw.

here's a piece of code as an example

PUBLIC SUB btVprint_Click()
  DIM NaamMaand[13] AS String
  DIM aantal AS Integer
  DIM AantalInLijst AS Integer
  DIM HoeveelRec AS Integer
  DIM vYdim AS Integer
  DIM Teller AS Integer
  DIM TempDatum AS Date
  DIM TempDatum2 AS Date
  DIM AantalDagen AS Integer
  DIM EersteDag AS Integer
  DIM vCounter AS Integer
  DIM pEersteDag AS Boolean
  DIM vIndex AS Integer
  DIM vYnaam AS Integer
  NaamMaand[1] = (Januari)
  NaamMaand[2] = (Februari)
  NaamMaand[3] = (Maart)
  NaamMaand[4] = (April)
  NaamMaand[5] = (Mei)
  NaamMaand[6] = (Juni)
  NaamMaand[7] = (Juli)
  NaamMaand[8] = (Augustus)
  NaamMaand[9] = (September)
  NaamMaand[10] = (Oktober)
  NaamMaand[11] = (November)
  NaamMaand[12] = (December)
  IF PrintVerjaardagen.rbPrintLijst.Value = TRUE THEN 
IF Printer.Setup() THEN RETURN 
  Draw.Begin(Printer) 'Initialize the draw
  Printer.Orientation = 0
  Printer.Size = A4
  Draw.Font.Size = 18
  Draw.Font.Name = Arial
  Draw.Font.Underline = TRUE
  Draw.Font.Bold = TRUE
  Draw.Text((Verjaardagen )  PrintVerjaardagen.sbJaren.Value, 1800, 250)
  Draw.Line(300, 450, 4900, 450)
  Draw.Font.Underline = FALSE
  Draw.Font.Bold = FALSE
  vYdim = 550
  FOR aantal = 1 TO 12
Draw.Font.Size = 14
Draw.Font.Name = Arial
HoeveelRec = VulMaandLijst(aantal)
IF (vYdim + 130 + (PrintVerjaardagen.lstMaandlijst.Count * 100))  6750 
THEN 
  'New Page
  Printer.NewPage 
  Draw.Font.Size = 18
  Draw.Font.Name = Arial
  Draw.Font.Underline = TRUE
  Draw.Font.Bold = TRUE
  Draw.Text((Verjaardagen )  PrintVerjaardagen.sbJaren.Value, 1800, 
250)
  Draw.Line(300, 450, 4900, 450)
  Draw.Font.Underline = FALSE
  Draw.Font.Bold = FALSE
  vYdim = 550  
ENDIF 
Draw.Text(NaamMaand[aantal], 350, vYdim)
vYdim = vYdim + 130
Draw.Font.Size = 10
FOR AantalInLijst = 0 TO PrintVerjaardagen.lstMaandlijst.Count - 1
  PrintVerjaardagen.lstMaandlijst.Index = AantalInLijst
  Draw.Text(PrintVerjaardagen.lstMaandlijst.Text, 350, vYdim)
  vYdim = vYdim + 100
NEXT 
vYdim = vYdim + 100
  NEXT 
  Draw.End
  PrintVerjaardagen.Close
  ELSE 
IF Printer.Setup() THEN RETURN  
  pEersteDag = TRUE 
  Draw.Begin(Printer) 'Initialize the draw
  Printer.Orientation = 1
  Printer.Size = A4
  FOR aantal = 1 TO 12
TempDatum = Date(PrintVerjaardagen.sbJaren.Value, aantal, 1)
IF aantal  12 THEN 
  TempDatum2 = Date(PrintVerjaardagen.sbJaren.Value, aantal + 1, 1)
  AantalDagen = (DateDiff(TempDatum, TempDatum2, gb.Day))
ELSE 
  AantalDagen = 31
ENDIF 
EersteDag = WeekDay(TempDatum)
HoeveelRec = VulMaandLijst(aantal)
vIndex = 0
PrintVerjaardagen.lstMaandlijst.Index = vIndex
Draw.Font.Size = 18
Draw.Font.Name = Arial
Draw.Font.Bold = TRUE
Draw.Font.Underline = TRUE 
Draw.Rect(250, 750, 6435, 350)  
Draw.Text(NaamMaand[aantal]   -   PrintVerjaardagen.sbJaren.Value, 
3000, 800) 
Draw.Font.Underline = FALSE
Draw.Font.Size = 12
Draw.Text((Maandag), 380, 990)
Draw.Text((Dinsdag), 1310, 990)
Draw.Text((Woensdag), 2240, 990)
Draw.Text((Donderdag), 3170, 990)
Draw.Text((Vrijdag), 4100, 990)
Draw.Text((Zaterdag), 5030, 990)
Draw.Text((Zondag), 5960, 990)  
'first row
Draw.Rect(250, 1100, 920, 600)   'Maandag
Draw.Rect(1170, 1100, 920, 600)  'Dinsdag
Draw.Rect(2090, 1100, 920, 600)  'Woensdag
Draw.Rect(3010, 1100, 920, 600)  'Donderdag
Draw.Rect(3930, 1100, 920, 600)  'Vrijdag
Draw.Rect(4850, 1100, 920, 600)  'Zaterdag
Draw.Rect(5770, 1100, 920, 600)  'Zondag
'second row
FOR Teller = 250 TO 5770 STEP 920
  Draw.Rect(Teller, 1700, 920, 600)
NEXT
'third row
FOR Teller = 250 TO 5770 STEP 920
  Draw.Rect(Teller, 2300, 920, 600)
NEXT
'fourth row
FOR Teller = 250 TO 5770 STEP 920
  Draw.Rect(Teller, 2900, 920, 600)
NEXT   
'fift row
FOR Teller = 250 TO 5770 STEP 920
  Draw.Rect(Teller, 3500, 920, 600)
NEXT 
'sixt row
Draw.Rect(250, 4100, 920, 600)
Draw.Rect(1170, 4100, 920, 600)
'print the days in numbers and birthdays  
Draw.Font.Size = 14
vYdim = 1150  
FOR vCounter = 1 TO AantalDagen
  FOR Teller = 1 TO 7
IF EersteDag = 0 THEN
  Teller = 7
  EersteDag = 1
ELSE 
  IF pEersteDag = TRUE THEN 
Teller = 

Re: [Gambas-user] TableView.text conversion

2010-03-12 Thread Les Hardy
Keith Clark wrote:
 Les,

 Thanks, but I found that that was not actually my problem.  The problem
 showed up in sending data to a field in my database.  I just forgot to
 surround the field with single quotes!  Sometimes the simplest problem
 is hard to see!

 Keith

   
Yes, if its a string it will be ok.
I have some very simple gambas code for a 10 to 13 digit conversion, if 
it is of any use to you.

Regards
Les


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] de-selecting a multi-select filechooser

2010-03-12 Thread richard terry
I wondered if it was possible programatically to deselect a users multi select

ie, if I've an checkbox as an option for the user to set the 
Filechoose1.multi=true, and they change their mind  click it off, how does 
one remove the highlighted multiple selected files?

Regards

Richard

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] de-selecting a multi-select filechooser

2010-03-12 Thread Olivier Cruilles
Hello,

May be it works like that.
For my ColumnView I use this little code:

ColumnView1.Mode = Select.None
ColumnView1.Refresh
ColumnView1.Mode = Select.Multiple

Perhaps this a solution ?

Olivier Cruilles
Mail: linu...@club-internet.fr

Le 12 mars 2010 à 23:30, richard terry a écrit :

 
 I wondered if it was possible programatically to deselect a users multi select
 
 ie, if I've an checkbox as an option for the user to set the 
 Filechoose1.multi=true, and they change their mind  click it off, how does 
 one remove the highlighted multiple selected files?
 
 Regards
 
 Richard
 
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user
 





--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] de-selecting a multi-select filechooser

2010-03-12 Thread Stefano Palmeri
Il venerdì 12 marzo 2010 23:30:44 richard terry ha scritto:
 I wondered if it was possible programatically to deselect a users multi
 select

 ie, if I've an checkbox as an option for the user to set the
 Filechoose1.multi=true, and they change their mind  click it off, how does
 one remove the highlighted multiple selected files?

 Regards

 Richard


FileChooser1.SelectedPath = User.Home 'or the path you want to restart from

Stefano



 ---
--- Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] LostFocus() not working on ubuntu !

2010-03-12 Thread Benoît Minisini
 the (textbox) LostFocus() routine is working on Opensuse (with Gambas
 2.17) but not on Ubuntu (with Gambas 2.19)!
 The same components of Gambas are loaded on both PCs!
 gb, gb.db, gb.db.form, gb.form, gb.image, gb.net, gb.qt, gb.qt.ext,
 gb.vb.

Several differences are mixed (version and distribution), so it is hard to 
guess where the problem comes from!

Is it possible for you to write a little project that isolates the problem? A 
little project with a LostFocus() that works on OpenSuSE with Gambas 2.17, and 
not on Ubuntu with Gambas 2.19.

Regards,

-- 
Benoît Minisini

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Using a printer documentation

2010-03-12 Thread Benoît Minisini
 Could someone forward me a few links about how to use a printer from
 within Gambas?  I need to know how to Print to a system default
 printer.
 
 Thanks
 
 Keith
 
 
In Gambas 2 or Gambas 3 ?

-- 
Benoît Minisini

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user