473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to format MSFlexgrid Colum

284 100+
I am using vb6.

I had placed an MSFlexGrid control in my form , the colum(3) contain quanity of the products.

Currently , the quantity is shouwing like

Expand|Select|Wrap|Line Numbers
  1. 10
  2. 1500
  3. 200
I want to show it like

Expand|Select|Wrap|Line Numbers
  1. 10.00
  2. 1500.00
  3. 200.00
  4.  
I know how to make it round for text boxes to two decimal places by using

Expand|Select|Wrap|Line Numbers
  1. Format(Round(quantity.Text, 2), "##0.00")
But how can I use the same code in MSFlexGrid.

Any help?
Jun 27 '10 #1
4 11066
Guido Geurs
767 Expert 512MB
It's the same: when adding the value to the grid, format the value like:

Expand|Select|Wrap|Line Numbers
  1.    For idx = 1 To 10
  2.       MSHFlexGrid1.AddItem (idx & vbTab & Format(Round(idx * 100, 2), "##0.00"))
  3.    Next
this will give=
1 | 100.00
2 | 200.00
...
Jun 27 '10 #2
muddasirmunir
284 100+
I am using the following function , where there is no syntax like .additem

I am posting my syntax , please guide me how to achieve my goal with this

Private Function fillgrid()

Expand|Select|Wrap|Line Numbers
  1. Dim rs As Recordset
  2. Set rs = New Recordset
  3. rs.CursorLocation = adUseClient
  4. rs.CursorType = adOpenStatic
  5. rs.LockType = adLockOptimistic
  6.  
  7. If rs.State = adStateOpen Then
  8. rs.Close
  9. End If
  10.  
  11. Dim sSQL As String
  12. sSQL = "my query"
  13. rs.Open sSQL, con
  14.  
  15. Dim i As Integer
  16. Dim j As Integer
  17.  
  18.  
  19. grid1.FixedRows = 1
  20. grid1.FixedCols = 0
  21.  
  22. If Not rs.EOF Then
  23.  
  24. grid1.Rows = rs.RecordCount + 1
  25. grid1.Cols = 1rs.Fields.Count
  26.  
  27. For i = 0 To rs.Fields.Count - 1
  28. grid1.TextMatrix(0, i) = rs.Fields(i).Name
  29. Next
  30.  
  31. i = 1
  32. Do While Not rs.EOF
  33.  
  34. For j = 0 To rs.Fields.Count - 1
  35. If Not IsNull(rs.Fields(j).Value) Then
  36. grid1.TextMatrix(i, j) = _
  37. rs.Fields(j).Value
  38. End If
  39. Next
  40.  
  41. i = i + 1
  42. rs.MoveNext
  43. Loop
  44.  
  45. PopulateFlexGrid = True
  46. End If
  47.  
  48.  
  49. End Function
Jun 27 '10 #3
QVeen72
1,445 Expert 1GB
Hi,

Change the Populate code like this :

Expand|Select|Wrap|Line Numbers
  1.   For j = 0 To rs.Fields.Count - 1 
  2.    If Not IsNull(rs.Fields(j).Value) Then 
  3.     If j = 3 Then
  4.      grid1.TextMatrix(i, j) = Format(rs.Fields(j),"0.00")
  5.     Else
  6.      grid1.TextMatrix(i, j) = rs.Fields(j).Value 
  7.     End If
  8.    End If 
  9.   Next 
  10.  
Regards
Veena
Jun 28 '10 #4
muddasirmunir
284 100+
@QVeen72
Thanks , Qveen72 , that works
Jun 28 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Henrik | last post by:
hi how can i hide a row or colum still containing data in a msflexgrid -- Best regards henrik
5
by: MouseHart | last post by:
I've written a simple program in VB 6.0 to list all my MP3 files. To show them on the screen I used an MSFlexGrid named TextGrid (which is not associated with any table or text file) in the...
0
by: Ed | last post by:
Hi, I am using an MSflexgrid in my c# code. I have a strange problem. My MSflexgrid has only 1 column. Now the data in that column can be long. WIth just 1 column the MSflexgrid does not show...
0
by: Martin K | last post by:
Hello all..thanks for everyone's advice regarding my SHBrowseForFolder API problem, I was able to put together a public class that runs great! But I have another migration headache regarding the...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
3
by: kies | last post by:
Hi everyone, I'm new to vb6 and i'm pretty stuck. I was wonndering if anyone can tell me or direct me to some code snipets with regards to retieving the text displayed in an entired colum in the...
1
by: zoneal | last post by:
Hi, I am involved in the process of migrating vb(6.0) application to vb.net. My application contains only vb controls namely MSFLEXGRID. I want to migrate my application to vb.net completely...
1
by: Steven | last post by:
I develop the application which contains MSFlexGrid to display data. When I try to fill the grid with the text data, I want to adjust the column width so that the width is adjusted to the maximum...
5
by: Ishmael | last post by:
Hi Is Been a 3 Yrs Now (I Still trying to do this) Please help me to do this with Visual Basic 6.0 using Msflexgrid Let say you are the Principal . You have 10 educators and 5 class (Grades)...
4
by: farhanm84 | last post by:
I have a requirement to display the link in colum format in IE browser. The link text is associated with an image (double arrow). Since the text of the link is large enough to set in one of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.