473,511 Members | 15,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Incorrect results calculated from MSFlexGrid

Mas Juliza Alias
67 New Member
hi, i use codes from Guido Geurs "Read and display specific data_v5.3.zip" from my previous thread below:
http://bytes.com/topic/visual-basic/answers/896473-read-display-specific-data-text-file-into-listbox-using-vb-6-a#post3621111

the data used is "Datum_0.txt" but the results in Form_Calculate are incorrect (see attachment). they should be 0.0, 41.0, 92.9, 157.0, 234.5, 326.7. i don't know what was wrong. Guido Geurs, i really need your help here... thank you.
Attached Images
File Type: jpg 1.jpg (49.4 KB, 318 views)
File Type: jpg 2.jpg (21.4 KB, 220 views)
Nov 24 '10 #1
9 2085
Guido Geurs
767 Recognized Expert Contributor
I'm using VB6 SP6 on XP SP3.
Is it possible to attach Your compilation of the program in Bytes so I can do a test on my PC and see of I also get the wrong results?

Is it possible to do a test on an other PC with XP ?

Can You set a breakpoint in the program on the calculation and watch what is happening with the values of "Val(ARRAYDATA(ARRAYDATAidx - 1).CUTVOL" and "Val(.TextMatrix(ARRAYDATAidx - 1, 1))" ?
Nov 25 '10 #2
Mas Juliza Alias
67 New Member
i'm using Vista. is that the problem?how if there are users of this program using Vista. will they get the wrong results though? i just use the program from your last attached file from previous thread. i am not yet compile it with my program since i got the incorrect results.

the problem is all PCs in this room are using Vista. but if that is the real problem i'll find PC with XP from outside.

i am sorry that i don't familiar with this breakpoint. i read through about breakpoint from books and try to set it in the program but somehow i don't get what to see from it. can you explain about it in simpler words? sorry for my limited knowledge.
Nov 26 '10 #3
Guido Geurs
767 Recognized Expert Contributor
Attached is a document, explaining the use of Breakpoint(s).
Attached Files
File Type: zip How to use breakpoints.zip (62.9 KB, 94 views)
Nov 26 '10 #4
Guido Geurs
767 Recognized Expert Contributor
I have done some tests in Vista and I have also the bad results.
It's solved when You change the code from "Val" to "CSng" in the calculation.

Expand|Select|Wrap|Line Numbers
  1.          MSFlexGrid1.AddItem ARRAYDATA(ARRAYDATAidx).DEPTH1 & vbTab & _
  2.             CStr(Format(CSng(ARRAYDATA(ARRAYDATAidx - 1).CUTVOL) + _
  3.             CSng(.TextMatrix(ARRAYDATAidx - 1, 1)), "#.0"))
Nov 27 '10 #5
Mas Juliza Alias
67 New Member
thank you for the explanation of breakpoints. it is much understandable than from the books!

i have changed the Val to CSng. it does solve the incorrect numbers but they are not in the form that they should be. the answer in Calculation form appears
0.0
410,0
929,0
1570,0
2345,0
3267,0

where they should be
0.0
41.0
92.9
157.0
234.5
326.7

how can we fix this? by the way, can you briefly explain the different between using Val and CSng? how can CSng solve the incorrect answers?

thank you for your help...
Dec 3 '10 #6
Guido Geurs
767 Recognized Expert Contributor
When the string "41.0" is interpreted as 410 then it means that the decimal symbol DOT isn't recognized as border between units and decimals in the CSng() function.
The "decimal simbol" is different in the "Regional and Language Options" and the data in the document.
See attached GIF files Region1.gif and Region2.gif.
How to modify: see GIFs Region3.gif and Region4.gif or build in the program a function with Replace(...) so the user can change the DOTs to COMMAs and vice versa.
I have also searched the internet and found a lot of calls of users who had problems with VB6 on Vista.
Maybe it's better to change to VB.net if all the users are on Vista ?
Dec 4 '10 #7
Mas Juliza Alias
67 New Member
i am sorry but you have not attached any file in your post. i can't find the GIF files you mentioned.
Dec 6 '10 #8
Mas Juliza Alias
67 New Member
i changed the decimal symbol from COMMA to DOT in the Regional and Language Option and i get the number form that i needed!! thanks to YOU! :)
Dec 6 '10 #9
Guido Geurs
767 Recognized Expert Contributor
Sorry, here they are.
Instead of always changing the regional setting, it's also possible to let the user change the data in the list with a command button with a For...next and the function Replace().


Expand|Select|Wrap|Line Numbers
  1. Private Sub ComRegional_Click()
  2. Dim ROWidx As Integer
  3. Dim COLidx As Integer
  4.    With MSFlexGrid1
  5.       For ROWidx = 1 To .Rows - 1
  6.          For COLidx = 0 To .Cols - 1
  7.             If .TextMatrix(ROWidx, COLidx) <> vbNullString Then
  8.                .TextMatrix(ROWidx, COLidx) = Replace(.TextMatrix(ROWidx, COLidx), ".", "C")
  9.                .TextMatrix(ROWidx, COLidx) = Replace(.TextMatrix(ROWidx, COLidx), ",", ".")
  10.                .TextMatrix(ROWidx, COLidx) = Replace(.TextMatrix(ROWidx, COLidx), "C", ",")
  11.             End If
  12.          Next
  13.       Next
  14.    End With
  15. End Sub
Attached Files
File Type: zip region_GIFs.zip (88.1 KB, 92 views)
Dec 6 '10 #10

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

Similar topics

9
6395
by: Chris Greening | last post by:
I'm seeing a very strange problem with outer joins. The example below replicates the problem: create table data1 (dim1 integer, stat1 float); create table data2 (dim1 integer, stat2 float); ...
0
1211
by: Ahmed | last post by:
Hi, I'm an Access newbie and I'm trying to create a simple report binded to a query which is: SELECT survey.q0_sex AS Gender, Count(survey.q0_sex) AS FROM survey WHERE q0_sex<>"" GROUP BY...
4
1876
by: seegoon | last post by:
Hi to all. I am pretty new to this stuff , so forgive me if I am asking the obvious. I am trying to extract some data from an Access database and am having some trouble. The SQL query that I am...
7
6482
by: reney | last post by:
I am trying to return the difference in minutes from a starttime and stoptime using the datediff function in a Web Project with VB.Net With: StartTime = 2/10/2006 8:46:03 PM EndTime = ...
4
2098
by: niko.nyman | last post by:
I noticed weird results when using eval() to do some simple calculations. Here are a few eval() statements and the corresponding results from JavaScript: eval("1.2+0.97") =2.17 eval("1.2+0.98")...
1
2663
by: bgreenspan | last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am doing and what I tried. My database has entries with Contract Names and Expiry Dates, among other fields. I have a form...
4
3361
by: Pietro Cerutti | last post by:
Hi group, #include <stdio.h> #include <unistd.h> #include <time.h> int main(void) { time_t t1, t2; char *st1, *st2;
0
1784
by: brunodamato | last post by:
In the example that follows, I am receiving an incorrect result set in the View. I am looking to get the FULL result set from View_LY and Table_TY. Instead, this View is returning the Common (Equi)...
3
1833
by: Jensen.Katie | last post by:
I have a SQL Server 2005 DB that I set up an ODBC connection to so that people can access the data through MS Access. There are 3 tables, each of which have a date column that is a varchar (20)...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.