|
Hi,
First code clears worksheet from previous data and excel formulas. Then retrieves data from database to excelworksheet. So far so good.
To reduse calculation from excel formulas. The formulas are created after database retreaval. Due the nature of dynamic. I can't create formulas before data is retrieved because data is not static nor goes to known place.
Excel SUM-formulas goes nice, but when inserting IF-formula exceptions begin.
Globals.Sheet3.Cells(10, 10).Value = "=IF(B28=""X"";C8/C29*D29;(B8+1)*C8)"
or
Globals.Sheet3.Cells(10, 10).Formula = "=IF(B28=""X"";C8/C29*D29;(B8+1)*C8)"
Above statement produce underlying error message.
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll
I think this is some kind of bug, but does enybody know a way to go around it?
Actually Cells(10, 10) and B28, C8 and D29 values are from variables that are calculated from data. I tried to insert any If formula to excel using VSTO2005 but result was same exception.
Pete
|
|
|
|
|
The bug is in your code. You're getting the COM exception because you're doing something that Excel doesn't like. In the Excel If function, the condition, true and false expressions must be sperated by commas, not semicolons.
|
|
|
|
|
|
I have a timer thread that calls a function with the following code:
Dim i As Integer = CType(RichTextBox1.Lines.Length / 2, Integer)
While i > 0
If RichTextBox1.InvokeRequired() Then
' Invoke the delegate.
Me.Invoke(m_RemoveLinesRichTextBoxDelegate)
Else
RichTextBox1.Lines(0).Remove(0, RichTextBox1.Lines(0).Length)
End If
i -= 1
End While
I like to remove sort of 50% of the lines in the RichTextBox
The delegate does contain the same line as if the invoke is not required, the delegate is setup fine.
The problem. Well it does not seems to remove the line. Anyone can explain me how to do it correct?
I am working with .NET 1.1
Thanks
|
|
|
|
|
strings are immutable, so string.Remove() returns a new string, it does not modify an
existing string.
Why not RichTextBox1.Lines(0)="" ?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
My code is like this to assign values to an integer array but i am getting an error like Object reference not set to an instance of an object...
Dim StepNumber() As Integer = Nothing
Dim Aindx As Integer = 0
ds = bl.GetStepDS(Session.Item("TestCase").ToString())
For Each record As DataRow In ds.Tables(0).Rows
StepNumber(Aindx) = Aindx
StepNameList(Aindx) = record.Item(0).ToString()
Aindx = Aindx + 1
Next
Can anybody please help me how to create and use Integer array?
Thanks in advance
|
|
|
|
|
Your array is not instanciated, try
Dim StepNumber() As Integer = new integer() {}
|
|
|
|
|
kokilaB wrote: Dim StepNumber() As Integer = Nothing
You declared an unbound array of Integers, then set it to Nothing. Bad idea.
You also cannot assign values to an unbound array. The array has to have bounds in order to use it.
ds = bl.GetStepDS(Session.Item("TestCase").ToString())
If ds.Tables.Count > 0 Then
If ds.Tables(0).Rows > 0 Then
Dim StepNumber(ds.Tables(0).Rows.Count - 1) As Integer
For Aindex As Integer = 0 to ds.Tables(0).Rows.Count - 1
StepNumber(Aindex) = Aindex
StepNameList(Aindex) = record.Item(0).ToString()
Next
'
' Do whatever you need to save and/or return the array here, because
' it won't exist outside this nested If statement.
'
End If
End If
|
|
|
|
|
Hi,
Kindly see the codes below:
On the next button I call ShowReconcileStatement.
In ShowReconcileStatement I call GetGridTotal.
When I call the GetGridTotal, Before it enters the procedure, I get an exception as : Object reference not set to an instance of an object. The code where the exception occurs I have underlined.
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Try
tcBankReco.SelectedIndex = 1
ShowReconcileStatement()
Catch ex As Exception
End Try
End Sub
Private Sub ShowReconcileStatement()
Try
Dim i As Integer
Dim bnkDep As Double = 0
Dim bnkWith As Double = 0
bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index)
bnkDep = GetGridTotal(dgtmp, dgtmp.Cols(DEPOSITS).Index)
Catch ex As Exception
End Try
End Sub
Private Function GetGridTotal(ByVal dg As C1.Win.C1FlexGrid.C1FlexGrid, ByVal col As Int16) As Double
Try
With dg
Dim rg As CellRange = .GetCellRange(1, col, dg.Rows.Count - 1, col)
Dim agg As String = .Aggregate(AggregateEnum.Sum, rg)
Return CDbl(agg)
End With
Catch ex As Exception
Return 0
ShowMessage(ex.Message, 30)
Finally
End Try
End Function
Please suggest..
Thanks and Regards,
|
|
|
|
|
Your dgtmp FlexGrid is not instantiated.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
Dot Net Jantu wrote: bnkWith = GetGridTotal(dgtmp, dgtmp.Cols(WITHDRAWLS).Index)
Your code is assuming that dgtmp.Cols(WITHDRAWLS) is returning an object. If it doesn't return an object, meaning that it returns Nothing , calling the Index property on it will throw this exception.
|
|
|
|
|
Hi All
how to get the DateTime value of a remote mahine.
By
George Garvasis
|
|
|
|
|
I don't know if there is a library for this but using command prompt may be a way.
Use command prompt:
net time \\Computename > C:\temp\time.txt
and parse time.txt to get the time.
For other options use:
net time /?
Hard way but it may do the work
Pete
|
|
|
|
|
any suggestions how to solve my problem in viewing my crystal report in vb.net 2003 :
an unhandled exception of type 'System.ExecutionEngineException' occured in crdb_adoplus.dll
thanks in advance!!!
jyn
|
|
|
|
|
Try this[^] list of possibilities. Since you haven't provided any detail about the problem, other than you have one, it's impossible to tell you how to fix it.
|
|
|
|
|
Hi, I've tried to open a file that is placed in a folder of web application in a editor that is made using windows application. Let us suppose i have a folder in http://localhost/MySite/MyFolder/doc.doc. Now what i need to do i want to open this file in that editor. I also want to display the file names of MyFolder. Please help me out and let me know is there any way to do so. It will be very nice of you.
Arslan Ilyas
|
|
|
|
|
|
hi all
i have a datagridview contains three columns with first column contains checkboxes.
i am trying to do that,
while keeping the control key pressed, try to navigate between cells.
but when i try to do that it select only the first row or the last row of datagridview.
some suggest me what should be done to do that or any thing else.
thanks in advance.
help everyone
|
|
|
|
|
That's the normal behavior of the DGV. If you hold down the Ctrl key, pressing Up or Down will put the focus on the first or last row of the DGV. You can change it and replace the functionality if you want by handling the DGV's KeyDown and KeyUp events and supplying the code to do whatever it is you want to do. I highly suggest reading up on the KeyDown, KeyUp, and KeyPress events, so you understand what you need to handle and what you need to do to tell your app that your code has handled keypresses and that the control should NOT try to handle them.
|
|
|
|
|
Hi everybody,
I wonder if anybody can enlight me on this matter! How can I force the premature termination of a background thread? I need to immediately terminate a thread, that could still be running, when I go to a different section of the application.
This is how a create and start the tread:
Public oFireThread As Threading.Thread<br />
<br />
Public Sub Trigger_Thread()<br />
Dim oThreadPoint As New Threading.ThreadStart(AddressOf Load_Data)<br />
<br />
oFireThread = New Threading.Thread(oThreadPoint)<br />
oFireThread.IsBackground = True : oFireThread.Priority = Threading.ThreadPriority.Normal<br />
oFireThread.Start()<br />
End Sub
Please keep in mind that I use the object: oFireThread to start other threads as well!
Thank you so much for you brain-storm!
Alex.
|
|
|
|
|
I think this may help:
oFireThread.Abort()
Regards.
|
|
|
|
|
Hi Nilesh,
Unfortunately I have already tried that approach. It does not do the trick
oFireThread.Abort() : attempts to finalize the thread, after doing I do not know what. I need to force the inmediate termination of this thread by-passing any validations, safeguards, or whatsoever.
Thaks anyway!
Alex.
|
|
|
|
|
That's the only way to do it. Even using this method has it's risks. If your code isn't prepared to Abort, your thread could leave resources and memory orphaned. Stopping a thread immediately will make this situation worse.
|
|
|
|
|
Appreciate your time and help.
Have a good weekend!
|
|
|
|
|
Hi,
I have a asp:GridView on my webpage, and I trying to bind an ArrayList made up of a series of custom structures (myStructure). I want to bind this arraylist to my gridview... so far I have not succedded.
>> ASP GridView
<asp:GridView ID="myGridView" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="startDate" HeaderText="Start Date" />
<asp:BoundField DataField="duration" HeaderText="Start Time" />
</Columns>
</asp:GridView>
>> the structure
Dim myArrayList As ArrayList
Public Structure myStructure
Public startDate As Date
Public duration As String
End Structure
' the arraylist contains serveral myStructures
myGridView.DataSource = myArrayList
myGridView.DataBind()
>>
How would I bind this. I get this error "A field or property with the name startDate was not found on the selected data source."
Help please, I fairly new to all this...
Thanks so much in advance.
-- modified at 22:11 Thursday 22nd November, 2007
|
|
|
|