|
You Can Use:
Microsoft Visual Basic 2005 Power Packs
its simple and Easy to use
|
|
|
|
|
|
You appear to be fairly clueless to me.
1 - this is a question about ASP.NET
2 - help me pls urgent is not a valid subject, everyone could put that, everyone wants help, and thinks it's urgent. It's not. We don't care about your web app, or your attempts to steal credit for it.
3 - What you've given us is not sufficient to help you if we wanted to. What sort of answer are you expecting ? Go to file x and remove line 32 ? We don't even know what you're using.
You need to get a life. If you use other people's code, they are allowed to claim credit for what they gave you. Removing their logo is a form of intellectual theft, and no-one here will help you do it.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I have the following excel 2003 formatting to ask:
I am writing a Visual Basic.Net 2005 desktop application write out data
from a sql server 2005 database to a excel 2003 spreadsheet.
After you look at my questions you can see a portion of the code that I am
currently working with. if you can answer any of the questions below, I would
appreciate it.
I would like to know how to change the following code to do the following:
1. I would like to have the center data in most of the columns including
the column headers.
2. I would like to see all the data in all the cels including the column headers.
3. I would like the last column of the table to 'wraparound' to the next line and
display no more that 75 to 100 characters in a line. (The last column
is varchar(500) due to the messages that could be displayed.)
4. I would like the column headers to be BOLD and the font be Times new Roman
and be able to control the font size.
5. I would like the detail lines to be Times New Roman in a regular font size.
6. Some of the column headers are larger than the detail column. Thus I need the
column headers to wrap. Some of the column headers are larger four words
long. Thus, I do not want the column headers to 'wrap' in the middle of
a word. I would like the column headers only to wrap between words.
Private Sub ShowReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim xlClApp As Excel.ApplicationClass
Dim excelFile As String = " "
Dim dt As DataTable
Dim da4 As SqlDataAdapter
cnn4 = New SqlConnection(connectionString)
cmd4 = New SqlCommand("stored procedure name", cnn4)
cmd4.CommandType = CommandType.StoredProcedure
With cmd4
.Parameters.Add("@parm1", SqlDbType.VarChar).Value = strParm1
.Parameters.Add("@parm2", SqlDbType.VarChar).Value = strParm2
End With
da4 = New SqlDataAdapter(cmd4)
da4.Fill(ds4)
xlApp = New Excel.Application
xlClApp = New Excel.ApplicationClass
xlApp.Workbooks.Add()
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
xlApp.Visible = False
xlApp.ScreenUpdating = True
dt = ds4.Tables(0)
'Add the column headings for the from the dataset
Dim dc As DataColumn
Dim iCols As Int32 = 0
For Each dc In dt.Columns
xlWorkSheet.Range("A1").Offset(0, iCols).Value = dc.ColumnName
xlWorkSheet.Range("A1").Offset(0, iCols).Font.Bold = True
xlWorkSheet.Range("A1").Offset(0, iCols).BorderAround()
iCols += 1
Next
Dim iRows As Int32
For iRows = 0 To dt.Rows.Count - 1
xlWorkSheet.Range("A2").Offset(0, iCols).Select()
xlWorkSheet.Range("A2").Offset(0, iCols).Justify()
xlWorkSheet.Range("A2").Offset(0, iCols).WrapText = True
xlWorkSheet.Range("A2").Offset(iRows).Resize(1, iCols).Value = _
dt.Rows(iRows).ItemArray()
xlWorkSheet.Range("A2").Offset(0, iCols).BorderAround()
Next
excelFile = "c:\exceltst.xls"
xlWorkBook.Sheets("sheet1").SaveAs(excelFile)
xlWorkBook.Close()
xlApp.Quit()
xlWorkSheet = Nothing
xlWorkBook = Nothing
xlClApp = Nothing
da4.Dispose()
cmd4.Dispose()
cnn4.Close()
|
|
|
|
|
Most of your questions can be answered by recording macros from with Excel itself, and examining the resultant VBA code. Since you have already created the requisite Excel objects within your application, the VBA code can more or less be directly used in your code, with the correct references.
HTH
|
|
|
|
|
ChandraRam:
I have the following questions to ask you which include:
1. I am not certain of when I can use a recording macro in excel? I basically need to have the visual basic.net 2005 desktop application control the processing since it is the one the drives the generation of separate excel worksheets in distinct workbooks. (There is one worksheet per workbook since each spreadsheet is email and to differet customers.)
2. When I use the recroding macro, when it be before I create the excel object, while I am putting data into the excel object, or after the excel worksheet has been generated?
3. I am not certain where you are refering to using the VBA code. Am I including the VBA code in the following .NET code:
xlApp = New Excel.Application
xlClApp = New Excel.ApplicationClass
xlApp.Workbooks.Add()
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"),
Microsoft.Office.Interop.Excel.Worksheet)
xlApp.Visible = False
xlApp.ScreenUpdating = True
dt = ds4.Tables(0)
'Add the column headings for the from the dataset
Dim dc As DataColumn
Dim iCols As Int32 = 0
For Each dc In dt.Columns
xlWorkSheet.Range("A1").Offset(0, iCols).Value = dc.ColumnName
xlWorkSheet.Range("A1").Offset(0, iCols).Font.Bold = True
xlWorkSheet.Range("A1").Offset(0, iCols).BorderAround()
iCols += 1
Next
Dim iRows As Int32
For iRows = 0 To dt.Rows.Count - 1
xlWorkSheet.Range("A2").Offset(0, iCols).Select()
xlWorkSheet.Range("A2").Offset(0, iCols).Justify()
xlWorkSheet.Range("A2").Offset(0, iCols).WrapText = True
xlWorkSheet.Range("A2").Offset(iRows).Resize(1, iCols).Value = _
dt.Rows(iRows).ItemArray()
xlWorkSheet.Range("A2").Offset(0, iCols).BorderAround()
Next
excelFile = "c:\exceltst.xls"
xlWorkBook.Sheets("sheet1").SaveAs(excelFile)
4. How can I use VBA code here?
5. Here is my code so far:
Private Sub ShowReport_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles Button1.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim xlClApp As Excel.ApplicationClass
Dim excelFile As String = " "
Dim dt As DataTable
Dim da4 As SqlDataAdapter
cnn4 = New SqlConnection(connectionString)
cmd4 = New SqlCommand("stored procedure name", cnn4)
cmd4.CommandType = CommandType.StoredProcedure
With cmd4
.Parameters.Add("@parm1", SqlDbType.VarChar).Value = strParm1
.Parameters.Add("@parm2", SqlDbType.VarChar).Value = strParm2
End With
da4 = New SqlDataAdapter(cmd4)
da4.Fill(ds4)
xlApp = New Excel.Application
xlClApp = New Excel.ApplicationClass
xlApp.Workbooks.Add()
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"),
Microsoft.Office.Interop.Excel.Worksheet)
xlApp.Visible = False
xlApp.ScreenUpdating = True
dt = ds4.Tables(0)
'Add the column headings for the from the dataset
Dim dc As DataColumn
Dim iCols As Int32 = 0
For Each dc In dt.Columns
xlWorkSheet.Range("A1").Offset(0, iCols).Value = dc.ColumnName
xlWorkSheet.Range("A1").Offset(0, iCols).Font.Bold = True
xlWorkSheet.Range("A1").Offset(0, iCols).BorderAround()
iCols += 1
Next
Dim iRows As Int32
For iRows = 0 To dt.Rows.Count - 1
xlWorkSheet.Range("A2").Offset(0, iCols).Select()
xlWorkSheet.Range("A2").Offset(0, iCols).Justify()
xlWorkSheet.Range("A2").Offset(0, iCols).WrapText = True
xlWorkSheet.Range("A2").Offset(iRows).Resize(1, iCols).Value = _
dt.Rows(iRows).ItemArray()
xlWorkSheet.Range("A2").Offset(0, iCols).BorderAround()
Next
excelFile = "c:\exceltst.xls"
xlWorkBook.Sheets("sheet1").SaveAs(excelFile)
xlWorkBook.Close()
xlApp.Quit()
xlWorkSheet = Nothing
xlWorkBook = Nothing
xlClApp = Nothing
da4.Dispose()
cmd4.Dispose()
cnn4.Close()
Thanks!
|
|
|
|
|
I have an app the has a large complex window (it edits documents) that uses Pegasus controls.
On several of my machines the window opens in about 3 seconds.
With one particular customer it takes almost 11 seconds. They have just about the same hardware and O/S as I do (XP, sp 3). I had them install more memory, and that didn't help either.
I have added code to time events down to the millisecond - and have found the problem lies in the creation of the window. Loading the data and images is no problem - the times on all machines is about the same.
Any ideas?
|
|
|
|
|
I tell such people to buy better computers. If it takes that long, it takes that long. Does it take that long every time, or just the first time ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I tend to agree with you. But this has changed between versions of Pegasus controls.
|
|
|
|
|
So, it's Pegasus you need to talk to, right ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi,
look at Task Manager Performance for the CPU load while the app is starting.
If it is around 100% all the time, your app is wasting CPU cycles for some reason (do you have busy loops? polling loops?); if it is around 50% all the time, your app is busy and might be faster with more multi-threading (assuming you have a multi-core CPU); if it is rather close to zero for some time, you are waiting for something (are you accessing stuff on servers? on Internet?).
dBrong wrote: the problem lies in the creation of the window.
Then add more observation points until you got to the specific line that causes the delay.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Is there a way to preload the Pegasus Dll's?
Some users have delays of 11-20 seconds in the mybase.new method.
|
|
|
|
|
I'm not familiar with Pegasus, so I can't tell; you might contact the vendor about it.
Is there some license scheme, possibly contacting them in real-time over the Internet?
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I need help converting between hex, ascii and back.
I want to type in an alpha numeric like "ABC123" and save as a HEX formatted like this "## ## ## ## ## ## ## ## ## ## ## ##"
Then later read that stored value and return to the text of "ABC123"
I am having trouble reading it and returning to text.
Here is what I try.
value = value.Replace(" ", "")
While (zero)
shorthex = value.Substring(0, 2)
If shorthex = "00" Then
value = value.Substring(2, value.Length - 2)
Else
zero = False
End If
i = i + 1
End While
Dim b((value.Length / 2) - 1) As Byte
Dim x As Integer = b.Length - 1
For i = value.Length - 2 To 0 Step -2
b(x) = value.Substring(i, 2)
x = x - 1
Next
value = Long.Parse(value, Globalization.NumberStyles.HexNumber)
Dim test As String = System.Text.Encoding.ASCII.GetString(b)
When this is done test does not show the valid Text.
Any suggestions?
I can't think of anything cool and nerdy to say.
|
|
|
|
|
Hi Cory,
your question is not really clear to me. How would you turn a six-char string ABC123 into a 24-char string (ignoring spaces)?? Please provide a full example, and/or provide the code that does the expansion.
Anyway, here are some comments on the code shown:
1.
the code is not safe, what if value starts of with all zeroes in it?
2.
Long.Parse is returning a Long, you shouldn't assign the result to value since that is a string.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I want to get string from textbox and write to RFID device formatted in HEX "## ## ## ## ## ## ## ## ## ## ## ##"
so, my goal is to (i think) convert text into Ascii then into hex and then I can save into the format.
Then I want to read from RFID and convert back to the Text. So I think I take formatted hex and convert to hex number and then to ascii number then to Text.
I am getting screwed up on the steps.
I think this will do the Write.
Dim i As Integer
Dim x As Integer
'Create array
Dim bytearray(23) As String
For i = 0 To bytearray.Length - 1
bytearray(i) = "0"
Next
Dim hex As String
Dim text As String = ""
'Change Text into ASCII
hex = Strings.Asc(TextBox1.Text)
'Change Ascii into HEx
hex = Long.Parse(hex, Globalization.NumberStyles.HexNumber)
x = 0
'Put hex into Format
For i = hex.Length - 1 To 0 Step -1
bytearray((bytearray.Length - 1) - x) = hex.Substring(i, 1)
x += 1
Next
'Create full formatted string to write to RFID
If TextBox1.Text<> "" Then
For i = 0 To bytearray.Length - 1 Step 2
text = text + bytearray(i) + bytearray(i + 1) + " "
Next
text = text.Substring(0, text.Length - 1)
If "f" is typed in text box then text variable should say "00 00 00 00 00 00 00 00 00 00 02 58"
I need help converting that back to "f"
I can get it back down to 258 which I think is the hex. I need to know how to convert back to Ascii and then Text.
Any ideas?
Text
I can't think of anything cool and nerdy to say.
|
|
|
|
|
Hi,
AFAIK this is completely wrong.
1. it does not work at all for more than one character since Strings.Asc(string) only looks at the first character of the string.
2. the conversion for a single character does not work (well, it does convert, but in a nonsensical way)
The simple example where original text is "f", it is an ASCII character with numeric value 102 in decimal, which is 66 in hex.
Indeed the outcome of Strings.Asc(TextBox1.Text) is the number 102
ERROR1: you erroneously store that in the string variable named "hex" which now holds "102"
ERROR2: then you parse, i.e. decode, it as if it were a hex number, hence the result is the number 258 since 1*256+0*16+2*1 equals 258.
ERROR3: you again erroneously store that in the string variable named "hex" which now holds "258"
and finally you do a lot of moving around to get some zeroes and spaces
What you probably want is something along these lines:
Sub rfid2()
Dim maxChars As Integer = 12
Dim Text As String = "ABC123 f"
Console.WriteLine("Encoding """ & Text & """ in " & maxChars & " hex chars")
Dim length As Integer = Text.Length
Dim result As String = ""
Dim i As Integer
For i = 1 To maxChars - length
result = "00 " & result
Next
For i = 0 To length - 1
Dim chr As Integer = Strings.Asc(text.Substring(i, 1))
result = result & chr.ToString("X2") & " "
Next
Console.WriteLine("result=" + result)
End Sub
This generates "00 00 41 42 43 31 32 33 20 20 20 66 " where each of the characters is clearly visible in hex.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Ok, that works, but how do I take the ASCII and display the text?
I can't think of anything cool and nerdy to say.
|
|
|
|
|
Hi,
To reverse the process, you need to perform the reverse of the same steps, in reverse order.
AFAIK the reverse of Strings.Asc is Strings.Chr, and the reverse of int16.ToString("X2") is int16.Parse() where you will want the right NumberStyle. I leave the details for you to work out.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Got it! Thank you.
I can't think of anything cool and nerdy to say.
|
|
|
|
|
I would like to save the data logs from the serialport received events into a filename. The problem is, I am running a series of test using the queue collection and I want to save each test in a different filename, (e.g Test 1, Test 2, Test 3, etc). Is it possible to use savefiledialog with it? Or is there some other ways to get around to doing this?
|
|
|
|
|
Hi,
the SerialPort.DataReceived event runs on a separate thread since it is asynchronous to anything you are doing; as such you are not allowed to touch any Control (including Forms, dialogs, and SaveFileDialog object) unless you use the proper InvokeRequired/Invoke method.
Also it does not seem like a good idea to interact with the user from within the DataReceived event, since more data will be arriving while you are waiting for the user's reaction.
Furthermore, the SaveFileDialog is *not* for saving data to a file, it is intended for letting the user *choose* a filename. When you need several file names, you probably want an algorithm to generate a series of filenames (say test###.log where ### is a sequence number)
What you should do is collect the data as it comes in, using whatever means appropriate (maybe a List<string> or a List<byte[]> depending on whether you accept text or arbitrary bytes); and in a different part of your app process or save the data, and interact with the user if and when necessary.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
|
Before any off your settings are called so best bet is the application startup event.
|
|
|
|
|
I can only now delete numbers from acces 2003 and not text. I have tryd this diffrent code, and all of them only delete numbers Eg "888".
It cant delete "myname" or "1 myname" only if everthing is numbers
MyOledbCommand.CommandText = "DELETE * FROM tblokkies WHERE leidraad='" & ListBox1.Items(ListBox1.SelectedIndex) & "'"
MyOledbCommand.CommandText = "DELETE * FROM tblokkies WHERE leidraad = """ & ListBox1.Items(ListBox1.SelectedIndex) & """"
MyOledbCommand.CommandText = "DELETE * FROM tblokkies WHERE leidraad='" & ListBox1.Items(ListBox1.SelectedIndex).ToString() & "'"
My colums is only set to text and leidraad is the primary key.
I don't know if it has to do with my insert to the table, here is the code I am using.
MyOledbCommand.CommandText = "Insert Into Tblokkies " & "(leidraad,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12) " _
& "Values (" _
& "'" & String1 & "', " _
& "'" & String2 & "', " _
& "'" & String3 & "', " _
& "'" & String4 & "', " _
& "'" & String5 & "', " _
& "'" & string6 & "', " _
& "'" & string7 & "', " _
& "'" & string8 & "', " _
& "'" & string9 & "', " _
& "'" & string10 & "', " _
& "'" & string11 & "', " _
& "'" & string12 & "', " _
& "'" & string13 & "')"
|
|
|
|
|