|
Hi,
I am also using same thing in mine project, however I don't have enough time to look into your code but I am sending u mine code so it will be easy for u to check it out what was wrong with your code.mine code is error free. let u try it.........
Imports Microsoft.VisualBasic
Imports Excel
Imports System
Imports com.lowagie.text
Imports com.lowagie.text.Image
Imports pdfWriter = com.lowagie.text.pdf.PdfWriter
Imports com.lowagie.text.pdf.PdfPTable
Imports java.io
Public Const vbCenter = 2
Public Const vbRightJustify = 1
Public Const vbLeftJustify = 0
'/* Master Report Section Start * /
Public Function BranchMaintenanceReport(ByVal strSearchText As String, Optional ByVal strUserNo As String = "") As String
Dim objXL As New Excel.Application, wbXL As Excel.Workbook, wsXL As Excel.Worksheet
Dim intRow As Long, intCol As Long, intColCount As Long, intSNo As Long
Dim rs As New ADODB.Recordset, SQL As String
'Dim st As New ADODB.Stream
Dim psUtil As New PensionSystemUtil
Dim ctr As Integer
Dim tempDir As String, fileName As String, filePath As String
fileName = ""
intRow = 0
intColCount = 3
wbXL = objXL.Workbooks.Add
Try
'intRow = intRow + 1
'wsXL.Range(wsXL.Cells(1, 1), wsXL.Cells(1, intColCount)).Merge()
'SQL = "select * from sa_company_logo where company_code='" & p_company & "'"
'psUtil.ConnectToHDDB()
'rs = New ADODB.Recordset
'rs.Open(SQL, psUtil.conHD, 2, 3)
'If Not rs.EOF Then
' st = New ADODB.Stream
' st.Open()
' st.Type = ADODB.StreamTypeEnum.adTypeBinary
' st.Write(rs.Fields("company_logo").Value)
' If psUtil.IsPathExists(tempDir + "\CompanyLogo.jpg") Then
' psUtil.KillFile(tempDir + "\CompanyLogo.jpg")
' End If
' st.SaveToFile(tempDir + "\CompanyLogo.jpg", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)
' wsXL.Shapes.AddPicture(tempDir + "\CompanyLogo.jpg", _
' Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 0, 0, 650, 100)
' wsXL.Rows(1).RowHeight = wsXL.Shapes.Item(1).Height
' st = Nothing
'Else
'End If
'intRow = intRow + 1
''-> Cell 3,1 Report Name and Report Period
'SetFont("Branch Maintenance Report ", "Arial", 16777215, True, False, False, 16, vbCenter, 16711680, wsXL, 3, 1)
'wsXL.Range(wsXL.Cells(2, 1), wsXL.Cells(2, intColCount)).Merge()
If psUtil.ConnectToPFDB Then
tempDir = System.Configuration.ConfigurationManager.AppSettings("applicationHome") + _
System.Configuration.ConfigurationManager.AppSettings("tempDir") + strUserNo
If Not psUtil.IsPathExists(tempDir, True) Then
psUtil.MakeDir(tempDir)
End If
For ctr = 1 To wbXL.Sheets.Count - 1
wbXL.Sheets(ctr).Delete()
Next
wsXL = objXL.ActiveSheet
wsXL.Name = "BranchMaintenanceReport"
'-> Header Rows
intRow = intRow + 1
wsXL.Cells(intRow, 1).Value = "S.No."
wsXL.Cells(intRow, 2).Value = "Branch Code"
wsXL.Cells(intRow, 3).Value = "Branch Name"
For intCol = 1 To intColCount
wsXL.Cells(intRow, intCol).BorderAround(Excel.XlLineStyle.xlContinuous, XlBorderWeight.xlMedium, XlColorIndex.xlColorIndexAutomatic)
Next
SQL = "SELECT Branch_Code, Branch_Name FROM Branches WHERE (Deleted <> 'Y' OR Deleted IS NULL) "
If strSearchText <> "" Then
SQL += "AND Branch_Name LIKE ('" + strSearchText + "%') "
End If
SQL += "ORDER BY Branch_Name"
rs = New ADODB.Recordset
rs.Open(SQL, psUtil.conPF, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly)
intSNo = 0
Do While Not rs.EOF
intRow = intRow + 1
For intCol = 1 To intColCount
wsXL.Cells(intRow, intCol).BorderAround(Excel.XlLineStyle.xlContinuous, XlBorderWeight.xlMedium, XlColorIndex.xlColorIndexAutomatic)
Next
intSNo = intSNo + 1
wsXL.Cells(intRow, 1).Value = intSNo
wsXL.Cells(intRow, 2).Value = rs("Branch_Code").Value.ToString
wsXL.Cells(intRow, 3).Value = Trim(rs("Branch_Name").Value.ToString)
rs.MoveNext()
Loop
wsXL.Columns(1).columnWidth = 5
wsXL.Columns(2).columnWidth = 11
wsXL.Columns(3).columnWidth = 50
wsXL.Range(wsXL.Cells(1, 1), wsXL.Cells(intRow, 3)).WrapText = True
wsXL.Range(wsXL.Cells(1, 1), wsXL.Cells(intRow, 3)).VerticalAlignment = Excel.XlVAlign.xlVAlignTop
wsXL.PageSetup.CenterFooter = "Page &P of &N"
wsXL.PageSetup.LeftFooter = strUserNo
wsXL.PageSetup.RightFooter = Format(Now, "dd-MMM-yyyy HH:mm")
wsXL.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait
wsXL.PageSetup.PrintTitleRows = "$1:$1"
wsXL.PageSetup.Zoom = 70
'-> No Report Means Nil...
If intRow = 1 Then
intRow = intRow + 1
For intCol = 1 To intColCount
wsXL.Cells(intRow, intCol).BorderAround(Excel.XlLineStyle.xlContinuous, XlBorderWeight.xlMedium, XlColorIndex.xlColorIndexAutomatic)
Next
wsXL.Cells(intRow, 2).Value = "NIL"
Else
End If
fileName = "BranchMaintenanceReport-" + Format(Now, "dd-MMM-yyyy") + ".xls"
filePath = tempDir + "\" + fileName
If psUtil.IsPathExists(filePath) Then
psUtil.KillFile(filePath)
End If
wsXL.SaveAs(filePath)
Else
Throw New Exception("DB Connection Error")
End If
Catch ex As Exception
Throw ex
Finally
wbXL.Close(False)
objXL.Quit()
psUtil.CloseConnectionPF()
End Try
BranchMaintenanceReport = fileName
End Function
thanks
ashish
|
|
|
|
|
Hii To All,
I am using splitter Container in vb.net ,in that normally we have 2 panels and a splitter to move .
when i move the splitter a dark line is moving when i mouse up also it is staying as dark line .
How to remove this one when i mouse up or released ???????????
DVS
|
|
|
|
|
I want to display color with corresponding color name in combo box.In my program i used for this image list.In that i stored bmp images.But i want to display color name also.How i do that .My code is
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim items(Me.ImageList1.Images.Count - 1) As String
For i As Int32 = 0 To Me.ImageList1.Images.Count - 1
items(i) = "Item " & i.ToString
Next
Me.ComboBox1.Items.AddRange(items)
Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
Me.ComboBox1.DrawMode = DrawMode.OwnerDrawVariable
Me.ComboBox1.ItemHeight = Me.ImageList1.ImageSize.Height
Me.ComboBox1.Width = Me.ImageList1.ImageSize.Width + 18
Me.ComboBox1.MaxDropDownItems = Me.ImageList1.Images.Count
End Sub
Private Sub ComboBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
If e.Index <> -1 Then
e.Graphics.DrawImage(Me.ImageList1.Images(e.Index), e.Bounds.Left, e.Bounds.Top)
End If
End Sub
Private Sub ComboBox1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles ComboBox1.MeasureItem
e.ItemHeight = Me.ImageList1.ImageSize.Height
e.ItemWidth = Me.ImageList1.ImageSize.Width
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case (ComboBox1.SelectedIndex)
Case 0
TextBox1.ForeColor = Color.Red
Exit Select
Case 1
TextBox1.ForeColor = Color.Yellow
Exit Select
End Select
End Sub
End Class
When i add the following code in combobox1_Drawitem
e.Graphics.DrawString(items(e.Index), Me.Font, Brushes.Black, e.Bounds)
It is not working bcs when i set a color name in items(e.index))it is common to every image.How can i solve this problem.
|
|
|
|
|
|
Hi all,
Does VB.Net 2003, Supports XML Commenting. I tried this Function But it is not giving the desired output
'''<summary><br />
'''Function To make Connection to SOL server and Return the SQL Connection<br />
'''</summary><br />
'''<param Name="sServerName">The ServerName to be connected</param><br />
'''<param Name="sDataBaseName">The DataBase to be connected</param><br />
'''<remarks><br />
'''If the Function Succeeds it will return the Connection , Else it will return nothing<br />
'''</remarks>
Thanks
Dana
|
|
|
|
|
No in VS2003 only C# supports XML-Comments.
VS2005 supports those in VB.net too.
|
|
|
|
|
Thanks for the reply CKnig
Oh God.Any other Way ?
|
|
|
|
|
|
for giving user frienly messages while passing arguments
|
|
|
|
|
Hmm.. maybe there is some way by adding code-attributes to the methods but I don't know exactly which.
|
|
|
|
|
danasegaranea wrote: Does VB.Net 2003, Supports XML Commenting
Not out of the box, but there's an add-in that provides the functionality. It's called VB Commenter and was part of Powertoys for VS 2003. However, it seems to be rather difficult to locate now. It's not clear whether it's contained in this:
http://www.codeplex.com/PackInstaller[^]
Kevin
|
|
|
|
|
I want to display color image with corresponding color name in combo box.I got to display color in combobox not corresponding color name.
The code is
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim items(Me.ImageList1.Images.Count - 1) As String
For i As Int32 = 0 To Me.ImageList1.Images.Count - 1
items(i) = "Item " & i.ToString
Next
Me.ComboBox1.Items.AddRange(items)
Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
Me.ComboBox1.DrawMode = DrawMode.OwnerDrawVariable
Me.ComboBox1.ItemHeight = Me.ImageList1.ImageSize.Height
Me.ComboBox1.Width = Me.ImageList1.ImageSize.Width + 18
Me.ComboBox1.MaxDropDownItems = Me.ImageList1.Images.Count
End Sub
Private Sub ComboBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
If e.Index <> -1 Then
e.Graphics.DrawImage(Me.ImageList1.Images(e.Index), e.Bounds.Left, e.Bounds.Top)
End If
End Sub
Private Sub ComboBox1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles ComboBox1.MeasureItem
e.ItemHeight = Me.ImageList1.ImageSize.Height
e.ItemWidth = Me.ImageList1.ImageSize.Width
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case (ComboBox1.SelectedIndex)
Case 0
TextBox1.ForeColor = Color.Red
Exit Select
Case 1
TextBox1.ForeColor = Color.Yellow
Exit Select
End Select
End Sub
How i display corresponding color name in that combo box.
|
|
|
|
|
well - you managed to show the images .. the text is much simpler. Just add the following line just after your e.Graphics.DrawImage line:
<br />
e.Graphics.DrawString(items(e.Index),me.Font,Brushes.Black,e.Bounds)<br />
(didn't test it so there might be a typo but I guess you get the idea)
BTW: you should but handle the case where the current cell is focused - normaly you use the e.DrawFocusRectangle() but this is not the way here - maybe just draw a shading (with an almost transparent brush) over your picture?
|
|
|
|
|
I cant get .In Imagelist i used bmp image to set that color.When i typed the code that u given.Its not worked.Pls help me
|
|
|
|
|
sorry - did miss the problem with the items-list
you need to declare this not as a local variable in the constructor but as a private class field.
BTW: if you would say what error message you get we could help you better
|
|
|
|
|
Hi,
I want to encrypt a string in a text field and decrypt the value and display in another text field. Can anyone provide me a code for this in vb.net. Thanks in advance..
|
|
|
|
|
Have a look at the "System.Security.Cryptography.RijndaelManagedTransform" class.
The MSDN-help will provide you with infos and examples how to use this.
|
|
|
|
|
I tried the following code for encrypting and decrypting. I have encrypted a string in button1_click event. The problem here is that I cant able to pass the encrypted value in button2_click event...
Can anyone help me out to find what the problem here is????
Imports System
Imports System.Security.Cryptography
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Public original As String
Public roundtrip As String
Public encrypted As Byte()
Public myRijndael As New RijndaelManaged()
Function encryptStringToBytes_AES(ByVal plainText As String, ByVal Key() As Byte, ByVal IV() As Byte) As Byte()
' Check arguments.
If plainText Is Nothing OrElse plainText.Length <= 0 Then
Throw New ArgumentNullException("plainText")
End If
If Key Is Nothing OrElse Key.Length <= 0 Then
Throw New ArgumentNullException("Key")
End If
If IV Is Nothing OrElse IV.Length <= 0 Then
Throw New ArgumentNullException("Key")
End If
Dim msEncrypt As MemoryStream = Nothing
Dim csEncrypt As CryptoStream = Nothing
Dim swEncrypt As StreamWriter = Nothing
Dim aesAlg As RijndaelManaged = Nothing
Try
aesAlg = New RijndaelManaged()
aesAlg.Key = Key
aesAlg.IV = IV
Dim encryptor As ICryptoTransform = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV)
msEncrypt = New MemoryStream()
csEncrypt = New CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)
swEncrypt = New StreamWriter(csEncrypt)
swEncrypt.Write(plainText)
Finally
If Not (swEncrypt Is Nothing) Then
swEncrypt.Close()
End If
If Not (csEncrypt Is Nothing) Then
csEncrypt.Close()
End If
If Not (msEncrypt Is Nothing) Then
msEncrypt.Close()
End If
If Not (aesAlg Is Nothing) Then
aesAlg.Clear()
End If
End Try
Return msEncrypt.ToArray()
End Function
Function decryptStringFromBytes_AES(ByVal cipherText() As Byte, ByVal Key() As Byte, ByVal IV() As Byte) As String
' Check arguments.
If cipherText Is Nothing OrElse cipherText.Length <= 0 Then
Throw New ArgumentNullException("cipherText")
End If
If Key Is Nothing OrElse Key.Length <= 0 Then
Throw New ArgumentNullException("Key")
End If
If IV Is Nothing OrElse IV.Length <= 0 Then
Throw New ArgumentNullException("Key")
End If
Dim msDecrypt As MemoryStream = Nothing
Dim csDecrypt As CryptoStream = Nothing
Dim srDecrypt As StreamReader = Nothing
Dim aesAlg As RijndaelManaged = Nothing
Dim plaintext As String = Nothing
Try
aesAlg = New RijndaelManaged()
aesAlg.Key = Key
aesAlg.IV = IV
Dim decryptor As ICryptoTransform = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV)
msDecrypt = New MemoryStream(cipherText)
csDecrypt = New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)
srDecrypt = New StreamReader(csDecrypt)
plaintext = srDecrypt.ReadToEnd()
Finally
If Not (srDecrypt Is Nothing) Then
srDecrypt.Close()
End If
If Not (csDecrypt Is Nothing) Then
csDecrypt.Close()
End If
If Not (msDecrypt Is Nothing) Then
msDecrypt.Close()
End If
If Not (aesAlg Is Nothing) Then
aesAlg.Clear()
End If
End Try
Return plaintext
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
original = TextBox1.Text
encrypted = encryptStringToBytes_AES(original, myRijndael.Key, myRijndael.IV)
// "Trying to pass this encrypted value in button2_click event"
TextBox2.Text = Convert.ToBase64String(encrypted)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
roundtrip = decryptStringFromBytes_AES(encrypted, myRijndael.Key, myRijndael.IV) //"shows encrypted value is nothing"
TextBox2.Text = roundtrip
End Sub
End Class
|
|
|
|
|
Hi,
The simplest method of doing this is change the asci value of each character in the string to encrypt and to decrypt string convert acsi to its orignal value.
Hope this helps
|
|
|
|
|
Hi,
can u tell me how to convert strings like
12/06/2020 ,12-06-2007 etc in date format.
ex: 12/06/2007-------> 12-Dec-2006
12-06-2007-------> 12-Dec-2006
thanks & regards
|
|
|
|
|
Check this out _ I never used it myself - but stumbled over it over the last few days when trying to fix my late binding issue ..
It copied out of the Help index
Imports System
Public Class ChangeTypeTest
Public Shared Sub Main()
Dim d As [Double] = - 2.345
Dim i As Integer = CInt(Convert.ChangeType(d, GetType(Integer)))
Console.WriteLine("The double value {0} when converted to an int becomes {1}", d, i)
Dim s As String = "12/12/98"
Dim dt As DateTime = CType(Convert.ChangeType(s, GetType(DateTime)), DateTime)
Console.WriteLine("The string value {0} when converted to a Date becomes {1}", s, dt)
End Sub 'Main
End Class 'ChangeTypeTest
|
|
|
|
|
DateTime.TryParseExact method or TryParse/Parse with the right culture
|
|
|
|
|
Hi,
This is perfect
Date.Today.ToString("d-MMM-yyyy") to get the way we want.
u have to use , dd-M-YY (Format) like this for this search in net .
dvs
|
|
|
|
|
Hi,
Try this one
<br />
Dim d As Date<br />
Dim s As String<br />
s = "17-12-2007"<br />
d = CType(s, Date)<br />
s = Format(d, "d MMMM yyyy")<br />
MsgBox(s)<br />
Hope this helps
|
|
|
|
|
i am converting a consloe application from vb to c#,
can anybody help me here how to do this efficiently...
am stuck with somekeyword... like
VB.Command()
.... and one more thing what will be equivalet to module in case of C#
T@SU
|
|
|
|
|