|
Okay, break the statement into pieces:
- define a variable of type VisualStyles.CheckBoxState
- assign a value to it using If block
- pass the variable to CheckBoxRenderer.DrawCheckBox method as state parameter
|
|
|
|
|
Running this through http://codeconverter.sharpdevelop.net/SnippetConverter.aspx[^] produces:
CheckBoxRenderer.DrawCheckBox(e.Graphics, _
New Point(e.Bounds.X, e.Bounds.Y), _
e.Bounds, box.Text, Me.Font, _
(e.State And DrawItemState.Focus) = 0, _
If(box.CheckState, CheckBoxState.CheckedNormal, CheckBoxState.UncheckedNormal))
The usage of "If" inside expressions is new in VB9 (VS08), for older versions, use IIf or split it into two statements.
|
|
|
|
|
Have you tried looking at code converters through a google search? SharpDevelop had a good one a while back, you may want to look at it.
http://codeconverter.sharpdevelop.net/[^] is the one I used before. It is helpful
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have wrote below code for creating Text file and then after storing line by line value in Text File.
If Not System.IO.File.Exists(strFileName) Then
Dim fs As FileStream = File.Create(strFileName)
fs.Flush()
fs.Close()
End If
Dim ObjFile As StreamWriter
ObjFile = File.AppendText(strFileName)
ObjFile.WriteLine(Now() & "---" & strStatus & "---"&strErrMsg)
ObjFile.Flush()
ObjFile.Close()
My problem is while i am running my autoprocess in server it gives me error like "The process cannot access the file XYZ.txt because it is being used by another process"
What is wrong in this code as i had close file as well object also.
Thanks.
|
|
|
|
|
First, you can comment out the file creation since it is created if it doesn't exists. After that do you still have the problem?
Mika
|
|
|
|
|
I did not get you but i had change by code with below lines
SWObj = New StreamWriter(strFile, True)
SWObj.WriteLine(rno )
SWObj.Flush()
SWObj.Close()
And i commented lines which creating File.
Thanks
|
|
|
|
|
What I meant is that the documentation for AppendText says:
Remarks: This method is equivalent to the StreamWriter(String, Boolean) constructor overload. If the file specified by path does not exist, it is created. If the file does exist, write operations to the StreamWriter append text to the file
So you don't need to create the file. The following code is enough:
Dim ObjFile As StreamWriter
ObjFile = File.AppendText(strFileName) <------- File is created if necessary
ObjFile.WriteLine(Now() & "---" & strStatus & "---"&strErrMsg)
ObjFile.Flush()
ObjFile.Close()
Did this get the problem solved?
Mika
|
|
|
|
|
Yea, Thanks you so much...Appreciate you help..
|
|
|
|
|
|
Hello Experts!!
I am creating 2 datasets after retreiving infromation from excel sheet, now i want to store these datasets in a sql database.
any ideas how to get this done?
Thanks in Advance!!
|
|
|
|
|
Anything you tried??
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
I tried sqlbulkcopy and doesnt look good for me...
|
|
|
|
|
|
I will try this in the morning tomorrow and let you know,
can you type in 2 lines of code showing it with SqlDataAdapter?
I am not sure of the properties of it.
Thanks Mika!
|
|
|
|
|
|
|
Arrays are just like any other variable. If you want to preserve the value of an array between method calls, put the array declaration outside the method.
If by "different process" you mean different thread, that is more challenging. Not my field of expertise, but the technique should be the same as sharing any variables.
|
|
|
|
|
This thing has been kicking my a$# for 2 days.
All I wanted to do was iterate through a dataset and pick to columns of data to make an array to pass to plot some points on a graph, draw the graph and the plotted lines.
All works well but I can not figure out how to get the array of the data to the drawing sub....
Driving me crazy...
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Ah, so your question is, "I have an array; how do I pass it as a parameter?" Declare your drawing subroutine like this:
Private Sub PlotPoints(ByVal Points As Double())
(Code goes here)
End Sub You will notice the opening and closing parentheses after the As Double part. That tells the compiler to expect an array of Double (or whatever type) rather than a single value.
If you have a complex data type -- your point data is in the form of (x coordinate, y coordinate) -- you might find it easier to create a class, then generate and pass a list:
Public Class MyPoint
Public XCoord As Double
Public YCoord As Double
End Class
Private Sub PlotPoints(ByVal Points As List(Of MyPoint))
End Sub I've been doing .Net for so long at this point that I tend to prefer lists over arrays.
|
|
|
|
|
I got it
Thanks to all
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
What I want to do for my company is turn our price book into a desktop application. I figured I could use an external file for the price data, for future editing purposes. I've been trying to do this in different ways for a while now, and it's sort of frustrating (this is my first real exposure to database programming and the like).
So I'm trying to read an Excel File into a DataTable. I have a sub going, but for some reason I keep getting a null reference exception:
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Private Sub ReadExcelData()
'Try
xlBook = GetObject("C:\Documents and Settings\Administrator.OFFICE2\Desktop\Michael\All_Item_Prices_2008.xls")
Dim xlsSheet As Excel.Worksheet = xlBook.Worksheets(1)
xlBook.Application.Visible = True
xlBook.Windows(1).Visible = True
xlBook.Application.WindowState = Excel.XlWindowState.xlMinimized
Dim irow As Integer = 1
Dim icol As Integer = 1
'DataTable:
'104 Rows
'91 Columns icol irow
'For icol = 1 To 91
'xlsSheet.Cells(ROW, COLUMN).value
MsgBox(xlsSheet.Cells(1, icol).Value.ToString)
If xlsSheet.Cells(1, icol).Value <> Nothing Then
New_Column = New DataColumn _
(xlsSheet.Cells(1, icol).Value.ToString)
Else
New_Column = New DataColumn("FILLER " & icol)
End If
'*************************************************
'NULL REFERENCE HAPPENS HERE
ItemDataTable.Columns.Add(New_Column)
'NULL REFERENCE HAPPENS HERE
'*************************************************
'For irow = 1 To 104
'MsgBox(xlsSheet.Cells(irow, icol).Value)
'ItemDataTable.Rows.Add = xlsSheet.Cells(irow, icol).Value.ToString
New_Row = ItemTable.NewRow
New_Row.Item(icol) = xlsSheet.Cells(irow, icol).Value.ToString
'Next
'Next
'Catch
'End Try
End Sub
If someone can tell me either what I'm doing wrong, or knows a better way (I have all of the prices and stuff saved as an Excel spreadsheet), please let me know. I would really appreciate it!
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|
|
where have you declared your data table? Couldn't see the definition in the code you have posted.
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
Whoops!
Imports Microsoft.Office.Interop
Imports System.Runtime.InteropServices
Imports Microsoft
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim WithEvents xlBook As Excel.Workbook
'DataTable:
'104 Rows
'91 Columns
'*****************************
Dim ItemDataTable As DataTable
'*****************************
Dim con As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As New DataSet
Dim fileName As String = ""
Dim New_Column As DataColumn
Dim New_Row As DataRow
Dim ItemTable As New DataTable
Some of this stuff is unused in this example, like the OleDb stuff.
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|
|
CodeMonkey85 wrote: Dim ItemDataTable As DataTable
You have declared this table but not defined it. It must be null and hence the exception.
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
How would I define a DataTable? By the looks of it, you specify it as a source for another object or something.
This might not even be the right way to do what I want to do, bear in mind. I'm looking for any easy way to store the data from my sheet so that I can programmatically retrieve it.
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|