range

Find a string in a document and delete everything after it

大憨熊 提交于 2019-11-28 05:52:10
问题 I want to find a string in a word document and delete everything after it. What is the best way to do this without using the Selection object? 回答1: Use a Range object instead. Straight outta the Word 2003 help: If you've gotten to the Find object from the Range object, the selection isn't changed when text matching the find criteria is found, but the Range object is redefined. The following example locates the first occurrence of the word "blue" in the active document. If "blue" is found in

Subscript out of range error in this Excel VBA script

邮差的信 提交于 2019-11-28 05:42:51
问题 I would like to copy data from a CSV file into an Excel worksheet. There are 11 .csv files. So far I have this (it is a modified version from a previous post): Sub importData() Dim filenum(0 To 10) As Long filenum(0) = 052 filenum(1) = 060 filenum(2) = 064 filenum(3) = 068 filenum(4) = 070 filenum(5) = 072 filenum(6) = 074 filenum(7) = 076 filenum(8) = 178 filenum(9) = 180 filenum(10) = 182 Dim sh1 As Worksheet On Error GoTo my_handler For lngPosition = LBound(filenum) To UBound(filenum)

onChange event for HTML5 range

有些话、适合烂在心里 提交于 2019-11-28 05:10:41
Currently the onChange event on my range inputs is firing at each step. Is there a way to stop this event from firing until the user has let go of the slider? I'm using the range to create a search query. I want to be able to run the search every time the form is changed but issuing a search request at each step of the slider's movement is too much. Here's the code as it stands: HTML: <div id="page"> <p>Currently viewing page <span>1</span>.</p> <input class="slider" type="range" min="1" max="100" step="1" value="1" name="page" /> </div> JavaScript: $(".slider").change(function() { $("#query")

Excel VBA selecting multiple dynamic ranges

廉价感情. 提交于 2019-11-28 05:09:31
问题 I'm trying to selecting multiple dynamic range. Trying to use the union method and I'm getting Method 'Range' of 'object' Global Failed error on first Set line. Dim LR As Long LR = Range("A60000").End(xlUp).Row Dim R1, R2, R3, R4, R5, MultiRange As Range Set R1 = Range("A7,:A" & LR) Set R2 = Range("D7,:D" & LR) Set R3 = Range("G7,:G" & LR) Set R4 = Range("H7,:H" & LR) Set R5 = Range("J7,:J" & LR) Set MultiRange = Union(R1, R2, R3, R4, R5) MultiRange.Select Selection.Copy 回答1: The problem

Identify whether the selected text in a web page is bold nor not

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 04:45:58
问题 I am trying to identify whether a selected text (in Firefox) is bold or not? For e.g.: <p>Some <b>text is typed</b> here</p> <p>Some <span style="font-weight: bold">more text is typed</span> here</p> The user can either select a part of bold text, or the full bold text. Here is what I am trying to do: function isSelectedBold(){ var r = window.getSelection().getRangeAt(0); // then what? } Could you please help me? Thanks Srikanth 回答1: If the selection is within an editable element or document,

Python: Mapping from intervals to values

陌路散爱 提交于 2019-11-28 04:35:28
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 and p <= 500: return 2 elif p > 500 and p <= 800: return 3 elif p > 800 and p <= 1000: return 4 elif p > 1000: return 5 Which is IMO quite horrible, and lacks in that both the intervals and the return values are hardcoded. Any use of any data structure is of course possible

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

有些话、适合烂在心里 提交于 2019-11-28 04:30:58
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 9 11 to 15 12 to 14 13 to 20 The method should give me 1 to 9 11 to 20 Guess it would be called a union? I imagine the method signature could look something like this: public static IEnumerable<Range<T>> Collapse<T>( this IEnumerable<Range<T>>, IComparable<T> comparer) { ..

is there no way to create a reversed (i.e. right-to-left) selection from JavaScript?

♀尐吖头ヾ 提交于 2019-11-28 04:30:49
问题 I'm trying to create a selection that goes from right to left in the text, but it seems the DOM Range API doesn't let me do that. (I don't see anything about this in the spec - not that I read it closely - but all implementations seem to agree on not supporting it.) For example, given a very minimal document: data:text/html,<div> this is a test </div> I can use this script to enable editing and create a normal selection (for example from a bookmarklet, but line wrapping added for clarity):

Convert Excel Range to ADO.NET DataSet or DataTable, etc

﹥>﹥吖頭↗ 提交于 2019-11-28 04:30:21
问题 I have an Excel spreadsheet that will sit out on a network share drive. It needs to be accessed by my Winforms C# 3.0 application (many users could be using the app and hitting this spreadsheet at the same time). There is a lot of data on one worksheet. This data is broken out into areas that I have named as ranges. I need to be able to access these ranges individually, return each range as a dataset, and then bind it to a grid. I have found examples that use OLE and have got these to work.

Drag the Range of a UI Input Range Slider

被刻印的时光 ゝ 提交于 2019-11-28 04:10:34
<---------[]=====================================[]--------> 0 10 90 100 I need an input range slider with two handles to select a range, and the ability to drag the range (the equals signs in the above diagram). So, in the above example, start=10 and end=90, and it is dragged left by shifting the entire line between the two handles: <[]=====================================[]------------------> 0 80 100 Now Start is 0 and End is 80, accomplished without dragging the handles. What library offers this functionality? Thank you. Overview jQuery UI Slider widget extension for a rangeDrag feature.