Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Text Format


Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2004, 05:29 AM
GerardMcL GerardMcL is offline
Centurion
 
Join Date: Jul 2004
Location: Belfast
Posts: 113
Default Text Format


Hi,
I have a TextBox1, I set its properties -> DataField = Number with 3 Decimal Places

When the form opens a calculation is executed and it fills the Text box - the result of the calculation is
58.0000192802 (Or something like that)
And this is exactly how it appears in the Text Box

Why, Oh Why doesn't it format it to 3 decimal places?
Reply With Quote
  #2  
Old 10-18-2004, 05:38 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,929
Default

Because it's only used for databinding and not for formatting.
Use the Format function to format the data
Reply With Quote
  #3  
Old 10-18-2004, 05:42 AM
robertdeniro robertdeniro is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Durban, South Africa
Posts: 306
Default

The DataFormat property is only used when a control is bound to a datasource.

You need to use a function like FormatNumber to do this.
Code:
Text1.Text = FormatNumber(calcResult, 3)
Reply With Quote
  #4  
Old 10-18-2004, 07:29 AM
GerardMcL GerardMcL is offline
Centurion
 
Join Date: Jul 2004
Location: Belfast
Posts: 113
Default Grid Format

Quote:
Originally Posted by robertdeniro
The DataFormat property is only used when a control is bound to a datasource.

You need to use a function like FormatNumber to do this.
Code:
Text1.Text = FormatNumber(calcResult, 3)

Thanks for all the replies lads, now If I knew how to format a column in a MSFlexgrid everything would be just peachy creamy
Reply With Quote
  #5  
Old 10-18-2004, 07:31 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,929
Default

Code:
MSFlexGrid.TextMatrix(1,3) = FormatNumber(calcResult, 3)
Have a look at the FlexGrid Functions thread in the Code Library for all kind of Flexgrid samples.
Reply With Quote
  #6  
Old 10-18-2004, 07:54 AM
GerardMcL GerardMcL is offline
Centurion
 
Join Date: Jul 2004
Location: Belfast
Posts: 113
Default Set at Beginning

Quote:
Originally Posted by Flyguy
Code:
MSFlexGrid.TextMatrix(1,3) = FormatNumber(calcResult, 3)
Have a look at the FlexGrid Functions thread in the Code Library for all kind of Flexgrid samples.
Using one of the samples you placed on the tutorial ( thanks for that by the way )
I set the width and headings at Load()
Can I set the column width then

MSFlexGrid1.Col(1) = FormatNumber( ,3)
Im sure this wont work, but can it be done
Reply With Quote
  #7  
Old 10-18-2004, 07:58 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,929
Default

No it doesn't work that way.
The MSFlexGrid doesn't the have advanced column properties like it's commercial brother the vsFlexGrid.

You either have to loop through all values of the Flexgrid and reformat these values or format the values when they are assigned to the grid.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->