range

VBA point variable to range

Hi I want to point to a cell as a range in VBA. I've tried using: Dim range range = Sheet("sheet").Range("A1") But this just returns the value in the range. What I actually want is the range object so I can manipulate it, e.g. by setting range.Value = "Hello" Any ideas? ...

Determine if a number falls within a specified set of ranges

I'm looking for a fluent way of determining if a number falls within a specified set of ranges. My current code looks something like this: int x = 500; // Could be any number if ( ( x > 4199 && x < 6800 ) || ( x > 6999 && x < 8200 ) || ( x > 9999 && x < 10100 ) || ( x > 10999 && x < 11100 ) || ( x > 11999 && x < 121...

Problem detecting Newlines in JavaScript Range Object

I have some javascript that manipulates html based on what the user has selected. For real browsers the methods I'm using leverage the "Range" object, obtained as such: var sel = window.getSelection(); var range = sel.getRangeAt(0); var content = range.toString(); The content variable contains all the selected text, which ...

how many distinct numbers are from 1.5 x 10^(-45) to 3.4 x 10^38?

How many distinct numbers are from 1.5 x 10-45 to 3.4 x 1038 (IEE754 single precision floats)? ...

Fast Algorithm to Quickly Find the Range a Number Belongs to in a Set of Ranges?

The Scenario I have several number ranges. Those ranges are not overlapping - as they are not overlapping, the logical consequence is that no number can be part of more than one range at any time. Each range is continuously (there are no holes within a single range, so a range 8 to 16 will really contain all numbers between 8 and 16), b...

Python: Mapping from intervals to values

Hi, I'm refactoring a function that, given a series of endpoints that implicitly define intervals, checks if a number is included in the interval, and then return a corresponding (not related in any computable way). The code that is now handling the work is: if p <= 100: return 0 elif p > 100 and p <= 300: return 1 elif p > 300 ...

Refresh display of Range when ScreenUpdating is False

Hi Is there a way to refresh the display of only a specified range of cells from VBA, when ScreenUpdating = False? What I mean is the following: Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Range("A1").Calculate Range("A1").SomeFunctionThatRefreshesThis ... Karl ...

Selection StartContainer in IE

I have a selection object where in IE, I run range = selection.createRange(); I then try to get the startContainer but am unable to figure out how. All examples show me SETTING the startContainer, but I am basing this off highlighting text. How do I know which element to set it to without getting it first? I know in FireFox it's as ...

Find Colour Range

I want to find a range of colours from the value of one RGB value If I was given rgb(0,100,200) for example it would give me everything between rgb(0,0,255) and rgb(0,255,255). However not rgb(255,0,255). Similarly rgb(150,50,0). Return: rgb(255,0,0) and rgb(255,255,0). Not rgb(255,0,255). Making sense? Im using PHP ...

What's a good, generic algorithm for collapsing a set of potentially-overlapping ranges?

I have a method that gets a number of objects of this class class Range<T> { public T Start; public T End; } In my case T is DateTime, but lets use int for simplicity. I would like a method that collapses those ranges into ones that cover the same "area" but that do not overlap. So if I had the following ranges 1 to 5 3 to ...

C#: Combining adjacent ranges

As a follow up to the method that collapses overlapping ranges I thought I would try to create a method that combines adjacent ranges. Basically, after running the Collapse method you may end up with for example 1 to 5 and 6 to 10. I would like to combine those into one range, 1 to 10. This is what I have come up with so far, but it d...

Is there an equivalent of Pythons range(12) in C#?

This crops up every now and then for me: I have some C# code badly wanting the range() function available in Python. I am aware of using for (int i = 0; i < 12; i++) { // add code here } But this brakes down in functional usages, as when I want to do a Linq Sum() instead of writing the above loop. Is there any builtin? I guess I ...

GUI to set numeric ranges in Delphi

Once in a while I need a GUI to set numeric ranges, but so far I've never really found any component that does it nicely. I've attempted the following: 2 TTrackbars: 1 for min, 1 for max 2 TTackbars: 1 for min, 1 for range 2 TSpinEdit controls to type the numbers manually 1 TTrackbar control, with a little button to switch between ...

Linq: GetElementAt() equivalent for retrieving multiple items?

I have an collection of iQueryable objects. Looking through intellisense i see 'GetElementAt(int)' but what i actually want to do is return multiple elements - so something like GetElementAt(int startindex, int count) GetElementAt(int startindex, int endIndex). I cant seem to see this. Any ideas? The only other thing i can think of is...

Algorithm to look up the date range based on event date

I'm writing a PHP function that would use a table of sorts to look up which DB shard the application should go to, based on the datestamp I have. The shard configuration is something like this (pseudo-code): the first column is the date of the event I'm looking for and the 2nd is the shard the event resides in. pre-2008 -> shard1 2008-...

Unobtrusively swapping HTML by XMLHttpRequest

So, I have received a string of HTML from the server using Javascript. It should be relatively well formed, but each node does not necessarily have a common ancestor. Ex. Response: <li>Item 1</li> <li>Item 2</li> ... The purpose here is to replace HTML currently on the page with the HTML received from the server without requiring an i...

How to generate normally distributed random from an integer range?

Given the start and the end of an integer range, how do I calculate a normally distributed random integer between this range? I realize that the normal distribution goes into -+ infinity. I guess the tails can be cutoff, so when a random gets computed outside the range, recompute. This elevates the probability of integers in the range, ...

Make sure a range object doesn't start or end in the middle of a word

My application requires heavy use of ranges (https://developer.mozilla.org/en/DOM/range). In particular, users frequently highlight text and then manipulate it. Sometimes users accidentally highlight text that includes a fragment of a word, and this produces weird results. I'd like to be able to, given a range, check to see whether it s...

Infopath form-creating a date range to query

Is there a way to create a date range and query by that date range for an infopath form created with a database setup, actually a sql server. I have been trying to create a date range filter that can be used with the "drag query fields option" while developing a form. ...

Can a range be matched in Scala?

Is it possible to match a range of values in Scala? For example: val t = 5 val m = t match { 0 until 10 => true _ => false } m would be true if t was between 0 and 10, but false otherwise. This little bit doesn't work of course, but is there any way to achieve something like it? ...