473,386 Members | 1,763 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,386 software developers and data experts.

Help With Column Algorithm

Hi all, I've written a function to return true or false if the value I
supply to it is close to a predefined column:

Private Function IsOnColumn(ByVal Position As Integer) As Boolean
Const COLUMN_WIDTH As Integer = 100
Const SNAP_DISTANCE As Integer = 20

Return (Position Mod COLUMN_WIDTH > COLUMN_WIDTH - SNAP_DISTANCE
OrElse Position Mod COLUMN_WIDTH < SNAP_DISTANCE)
End Function

I've been trying to modify it so that the column detection shifts to the
left (COLUMN_WIDTH /2). So instead of the columns appearing at 0, 100, 200,
300 400 etc., they appear at 50, 150, 250, 350, 450 and so on, but I'm
pulling hair out!

Can anyone help?
Many thanks,
Chris.
Jan 20 '06 #1
2 1019
> Private Function IsOnColumn(ByVal Position As Integer) As Boolean
Const COLUMN_WIDTH As Integer = 100
Const SNAP_DISTANCE As Integer = 20
Return (Position Mod COLUMN_WIDTH > COLUMN_WIDTH - SNAP_DISTANCE
OrElse Position Mod COLUMN_WIDTH < SNAP_DISTANCE)
End Function

I've been trying to modify it so that the column detection shifts to the
left (COLUMN_WIDTH /2). So instead of the columns appearing at 0, 100, 200,
300 400 etc., they appear at 50, 150, 250, 350, 450 and so on, but I'm
pulling hair out!


If I understand correctly, you want position+(COLUMN_WIDTH /2) to behave
like position does in the above code. If that is true, insert
position -= (COLUMN_WIDTH /2)
after the const statements.

Jan 20 '06 #2
Thanks mate, I thought the answer would be a simple one, but after staring
at my monitor for so long, I was just going blind to all the Mod's and
COLUMN_WIDTH's!

Nice one,
Chris.

"AMercer" <AM*****@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
Private Function IsOnColumn(ByVal Position As Integer) As Boolean
Const COLUMN_WIDTH As Integer = 100
Const SNAP_DISTANCE As Integer = 20
Return (Position Mod COLUMN_WIDTH > COLUMN_WIDTH - SNAP_DISTANCE
OrElse Position Mod COLUMN_WIDTH < SNAP_DISTANCE)
End Function

I've been trying to modify it so that the column detection shifts to the
left (COLUMN_WIDTH /2). So instead of the columns appearing at 0, 100,
200,
300 400 etc., they appear at 50, 150, 250, 350, 450 and so on, but I'm
pulling hair out!


If I understand correctly, you want position+(COLUMN_WIDTH /2) to behave
like position does in the above code. If that is true, insert
position -= (COLUMN_WIDTH /2)
after the const statements.

Jan 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dr. Ann Huxtable | last post by:
Hello All, I am reading a CSV (comma seperated value) file into a 2D array. I want to be able to sort multiple columns (ala Excel), so I know for starters, I cant be using the array, I need...
1
by: neelu | last post by:
I have four columns in listview. SR Number Part# DES Qty Weight 59 9410106800 Nut 10 0.03 60 90304ge800 Helmet 5 0.325 61 9635439604 ...
5
by: sameer_deshpande | last post by:
Hi, I need to create a partition table but the column on which I need to create a partition may not have any logical ranges. So while creating or defining partition function I can not use any...
4
by: Farraige | last post by:
Hi I need your help... I am implementing the method that updates given table (table is represented as list of lists of strings) according to other table (some kind of merging)... This method...
2
by: Bernard Dhooghe | last post by:
The information center writes: "Encryption Algorithm: The internal encryption algorithm used is RC2 block cipher with padding, the 128-bit secret key is derived from the password using a MD2...
1
by: raghavshastri | last post by:
You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity. Here is a sample PGM image with 10...
1
by: flavourofbru | last post by:
Hi, I am stuck at a major part of the code in VC++. My algorithm is as follows: f_name = load(filename); //this also loads a text file. The text files contains numbers sepearted by tab....
1
by: Durango2008 | last post by:
Hi, I am having a bit of trouble with my gridview table and the width of the columns. The gridview is made of Templates that contain LinkButton controls. The LinkButtons will display a string...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.