|
Hi,
I am a beginner of VB2008 programming.
I tried to develop a simple class which takes array data and write them in Excel sheet as 2D array. However, it is not working. Could anyone tell me what went wrong? Here is my code.
Public Class WriteDtToExcel
Private ShNumber As Integer
Private CellX As Integer
Private CellY As Integer
Private ReadOnly DtA(CellX * CellY) As Double
Public Property SheetNumber() As Integer
Get
Return ShNumber
End Get
Set(ByVal value As Integer)
ShNumber = value
End Set
End Property
Public Property XSize() As Integer
Get
Return CellX
End Get
Set(ByVal value As Integer)
CellX = value
End Set
End Property
Public Property YSize() As Integer
Get
Return CellY
End Get
Set(ByVal value As Integer)
CellY = value
End Set
End Property
Public Sub New()
Dim i As Integer
For i = 0 To DtA.Length
DtA(i) = DtA.Length - i - 1
Next
End Sub
Public ReadOnly Property ArrayData() As Double()
Get
Return DtA
End Get
End Property
Sub WriteDtToExcel()
Dim objApp As Excel.Application
Dim objBook As Excel.Workbook
Dim objBooks As Excel.Workbooks
Dim objSheets As Excel.Sheets
Dim objSheet As Excel._Worksheet
Dim range As Excel.Range
Dim x As Integer
Dim y As Integer
' Create a new instance of Excel and start a new workbook.
objApp = New Excel.Application()
objBooks = objApp.Workbooks
objBook = objBooks.Add
objSheets = objBook.Worksheets
objSheet = objSheets(Me.SheetNumber)
'you can name the objsheet
'objSheet.Name = "First Sheet"
range = objSheet.Range("A1", Reflection.Missing.Value)
range = range.Resize(Me.XSize, Me.YSize)
'Set the range value to the array.
Dim PxDt(Me.XSize, Me.YSize) As Double
For y = 0 To Me.YSize
For x = 0 To Me.XSize
PxDt(x, y) = Me.ArrayData(Me.YSize * y + x)
Next
Next
range.Value = PxDt
'Return control of Excel to the user.
objApp.Visible = True
objApp.UserControl = True
'Clean up a little.
range = Nothing
objSheet = Nothing
objSheets = Nothing
objBooks = Nothing
End Sub
End Class
With my short knowledge, I was hoping to assign pixel size by:
WriteDtToExcel.xsize = 100: WriteDtToExcel.ysize=100: WriteDtToExcel.DtA=dtarray and so on, and then run the subroutine for data export to Excel.
Ofcause, it is not working at all.
Could someone advice me what was wrong with me.
cheers,
Whity Hwang
|
|
|
|
|
As a beginner, one of the most important things you need to learn about is the debugger. Look it up in the help and then step through your code to see what is going wrong.
With the information supplied its almost impossible to know what is wrong as you just say
SangGi Hwang wrote: Ofcause, it is not working at all
In what respect?
Anyway, try debugging and post more details when you know the exact error.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
How to convert speech to word converter...
give me idea for this...
thx in advance
kannan.c
|
|
|
|
|
Buy Dragon Naturally Speaking. Ponder why they'd create a whole product to do this, if it was so easy people could be told how to write it in a forum reply.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
If you want text to speech, then the System.Speech namespace should help. Try this article[^] for more information. However, this only works on version 3.0 of the .Net Framework and above. Otherwise, you'll need to use COM
|
|
|
|
|
hi...
I am entry level prog in vb.net..
Every day I want to take back file..
For Example,
2day we enter some data's in access DB.This DB ill take backup..Likewise everyday take backup...But only stored particular day entry only...finally merge all datas for month end...
i dont have idea for tis....Plz give me solution...
thx in advance...
Regards
kannan.c
|
|
|
|
|
m4kannan wrote: I am entry level prog in vb.net..
This task is well and truly beyond you if you're 'entry level'. If you want this for yourself, buy something. If you're being paid to write it, admit to your boss or client that they picked the wrong guy. I can't imagine it's homework.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
pls. help me...
i am having headache doing this barcode....i dont have any idea on how to generate numbers or letters into a barcode like EAN 13, Codebar, Code 128 etc.... i saw some activeX but all of them are demo.... Can someone help me or send me a source code on how to generate barcode? thank you very much in advance...
by the way, you can send me the code at jerome.mercado26@yahoo.com
thanks again.
i can help you in some codes for begginers.
|
|
|
|
|
jeje0926 wrote: i saw some activeX but all of them are demo....
Yes, typically, if the CP article on barcodes doesn't help, you'll need to buy something.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi
why dont you use a barcode font?
google for code3of9 barcode font.....
install it in your control panel/fonts and use it.
try this http://www.advancemeants.com/code39font/download.htm
thanks and hope it helps
|
|
|
|
|
Hi,
I make on OCX control as Alarmctrl.ocx thriugh VisualBasic 6.0.
And i use the control in another VB applcaiton of same version in my same machine,I added in components.and when i draged it into the form,it tells the following error.
"License information for this Component not found.You do not have an appropriate license to use this functionality in drsign environment"
How can i avoid tht.
I saw the article from MSDN and follow it but not working.
Pls help me out.
My visulabasic version is
Microsoft VisualBasic 6.0(SP6)
For 32-bit Windows Development.
Anu
|
|
|
|
|
Easily fixed with a little help from Google[^].
|
|
|
|
|
Hi,
I have one directory eith files and i want to copy one filr from that directory to another. For that i used the following code but it doesn't work.
Import System.IO
Filecopy(sourcepath, destinationpath)
Please let me know, here additionally i need to add any code...
Thanks in advance
Regards,
Samson
|
|
|
|
|
Well, where did you get this syntax from ? File.Copy will work. Filecopy will not, for obvious reasons.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
This also showing error like Could not find the part of the path
With Regards,
Samson
|
|
|
|
|
I am not sure that File.Copy will create directories that do not exist. Otherwise, if your paths exist, it should work fine ( of course, assuming the dest file does not exist, if it does, you need to pass true as the third param )
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
i have a crystal report.it takes time to load.so i would like to show the user that it is loading
so that like to know how can I create a progress bar that will show the progress of a loading crystal report in vb.net?
the time of to display progerss bar just before report open when the report are open than the progres bar dosen't show please help
if have a source code so please give it please
|
|
|
|
|
Well, I answered this yesterday. You did not respond. Why are you asking it again ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Ya But I Can't Understand Please if u have Some Code to please give or in can i use thread ?
but in this application how to use that's also i don't know so please if possible to give me some example or code to do this'
please
thanks you...
|
|
|
|
|
Hi Guys
How can I databind CheckedListBox with a multi dimensional array so that, one array value can be used as DataMember and other to be the value Member for the CheckedListBox. I want to allow the user to select fields from a DataTable for exporting DATA to a TextFile. Since the Field names in the DataTable are not meaningful to the user. I want a more descriptive Field name to be displayed on the screen. When user selects the decriptive field name I want to use the physical Fld name associated with it for selecting and exporting appropriate data.
Please help.....
|
|
|
|
|
I think there's no way to do this with databinding, you need to write a loop and add the items yourself.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Hello Everyone,
I need to send simple textual data on a serial port of a remote machine using VB.NET . I just need a Windows app. with A server and a client side s/w.
Please help me.
Fahad Siddiqui
|
|
|
|
|
Hmm, it will be very hard to help you as you didn't even ask a question.
But the most help I can give you right now is right here... Google[^]
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
(Using Visual Studio 2008)
I am trying to learn how to add functionality to the MonthCalendar control. I have looked at the C# example at this url http://www.codeproject.com/KB/selection/MonthCalendar.aspx[^]
However I am not a C# guy, and the custom control is a bit over kill.
Specifically, all I want to do is add the ability to set the color of a BoldedDate, either the forecolor or the back color. The C# example is nice, but it lacks the ability to have a 4x3 grid of calendars like the MonthCalendar has.
I have already created a Class with some code examples to add functionality for a double click event as follows:
Thanks
J
Public Class ExtendedMonthCalendar
Inherits MonthCalendar
Private m_LastClickPosition As Point
Private m_LastClickTime As Long
Private m_LastClickRaisedDoubleClick As Boolean
Public Shadows Event DoubleClick( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
#Region "Events"
Protected Overrides Sub OnDoubleClick(ByVal e As EventArgs)
RaiseEvent DoubleClick(Me, e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
If e.Button = MouseButtons.Left Then
If _
Not m_LastClickRaisedDoubleClick AndAlso _
Now.Ticks - m_LastClickTime <= _
SystemInformation.DoubleClickTime * 10000 AndAlso _
IsInDoubleClickArea(m_LastClickPosition, Cursor.Position) _
Then
OnDoubleClick(EventArgs.Empty)
m_LastClickRaisedDoubleClick = True
Else
m_LastClickRaisedDoubleClick = False
End If
m_LastClickPosition = Cursor.Position
m_LastClickTime = Now.Ticks
End If
MyBase.OnMouseDown(e)
End Sub
Private Function IsInDoubleClickArea( _
ByVal Point1 As Point, _
ByVal Point2 As Point _
) As Boolean
Return _
Math.Abs(Point1.X - Point2.X) <= SystemInformation.DoubleClickSize.Width AndAlso _
Math.Abs(Point1.Y - Point2.Y) <= SystemInformation.DoubleClickSize.Height
End Function
#End Region
End Class
|
|
|
|