VS 2013 : Project name with number in brackets

In file C:\Users\Username\Documents\IISExpress\config\applicationhost.config, under section

<sites>

</sites>

there was all websites (projects) I have ever opened. I deleted these items and now, on New Website there is no number in brackets. NOTE: I think it is not wise to delete the entire file but only the part that applies to sites/projects.

 

 

Reff: http://forums.asp.net/t/1953275.aspx?Project+name+with+number+in+brackets

Advertisements

Visual Studio 2013 Change the Default Location for Projects

For corporate office user my document is always redirected to a file server where creating exe file is restricted.

1. Create a folder in c drive called: vs 2013

2. Inside that folder create 2 folders

Projects

Templates

3. Inside Templates, create another 2 folders:

ItemTemplates

ProjectTemplates

4. Open visual studio and follow the steps

  • On the Tools menu, select Options.
  • From the Projects and Solutions folder, select General.
  • In the Visual Studio projects location text box, enter a location for files and projects.

 

vs2013

 

And you should be all set.

 

Remove spaces from a string in VB.NET

To remove ALL spaces:

 myString = myString.Replace(" ", "")

To remove leading and trailing spaces:

myString = myString.Trim()

Note: this removes any white space, so newlines, tabs, etc. would be removed.

By simplemsexchange Posted in VB.NET

Check Valid Email Function using C# and VB.NET

C#:

bool IsValidEmail(string email)
{
    try {
        var addr = new System.Net.Mail.MailAddress(email);
        return true;
    }
    catch {
        return false;
    }
}




VB:

Private Function IsValidEmail(ByVal email As String) As Boolean
        Try
            Dim addr = New System.Net.Mail.MailAddress(email)
            Return True
        Catch
            Return False
        End Try
    End Function
By simplemsexchange Posted in C#, VB.NET

Print SSRS report directly to a printer without viewing using vb.net

1. Add a form PrintReport.vb

2. Add a report viewer in the form. configure the report viewer property (server url, path)

3.  code behind:

 

Imports System.Drawing.Printing
Imports System.Drawing.Imaging
Imports System.IO
Imports Microsoft.Reporting.WinForms

Public Class PrintReport
Dim pages As New List(Of Metafile)
Dim pageIndex As Integer = 0
Dim doc As New Printing.PrintDocument()

Private Sub PrintReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim doc As New Printing.PrintDocument()
doc = New Printing.PrintDocument()
AddHandler doc.PrintPage, AddressOf PrintPageHandler
Dim dialog As New PrintDialog()
dialog.Document = doc
Dim print As DialogResult
print = dialog.ShowDialog()

doc.PrinterSettings = dialog.PrinterSettings

Dim deviceInfo As String = _
“<DeviceInfo>” + _
“<OutputFormat>emf</OutputFormat>” + _
”  <PageWidth>8.5in</PageWidth>” + _
”  <PageHeight>11in</PageHeight>” + _
”  <MarginTop>0.25in</MarginTop>” + _
”  <MarginLeft>0.25in</MarginLeft>” + _
”  <MarginRight>0.25in</MarginRight>” + _
”  <MarginBottom>0.25in</MarginBottom>” + _
“</DeviceInfo>”

Dim warnings() As Microsoft.Reporting.WinForms.Warning ‘Warning
Dim streamids() As String
Dim mimeType, encoding, filenameExtension, path As String
mimeType = “” : encoding = “” : filenameExtension = “”

‘Report Parameter Input. Add form text box as per your requirements

Dim SALES_ORDER_NUMBER As String
Dim INVOICE_NUMBER As String
SALES_ORDER_NUMBER = CRMInvoicing.txtSALES_ORDER_NUMBER.Text
INVOICE_NUMBER = CRMInvoicing.txtINVOICE_NUMBER.Text
Dim parmSO As New ReportParameter(“SALES_ORDER_NUMBER”, SALES_ORDER_NUMBER)
Dim parmI As New ReportParameter(“INVOICE_NUMBER”, INVOICE_NUMBER)
Dim parmSO1(1) As ReportParameter
parmSO1(0) = parmSO
parmSO1(1) = parmI

Dim data() As Byte
rpt_control.ServerReport.SetParameters(parmSO1)
data = rpt_control.ServerReport.Render(“Image”, deviceInfo, mimeType, encoding, filenameExtension, streamids, warnings)
pages.Add(New Metafile(New MemoryStream(data)))

For Each pageName As String In streamids
data = rpt_control.ServerReport.RenderStream(“Image”, pageName, deviceInfo, mimeType, encoding)
pages.Add(New Metafile(New MemoryStream(data)))
Next
doc.Print()

Me.rpt_control.RefreshReport()
End Sub

Private Sub PrintPageHandler(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim page As Metafile = pages(pageIndex)
pageIndex += 1
Dim pWidth As Integer = 827
Dim pHeight As Integer = 1100
e.Graphics.DrawImage(page, 0, 0, pWidth, pHeight)
‘e.Graphics.DrawImage(page, 0, 0, page.Width, page.Height)
e.HasMorePages = pageIndex < pages.Count
End Sub

End Class

 

 

Further Details here

Get first day of the month and last day of the month in VB.NET

Private Function GetFirstDayOfMonth(ByVal dtDate As DateTime) As DateTime
        Dim dtFrom As DateTime = dtDate
        dtFrom = dtFrom.AddDays(-(dtFrom.Day - 1))
        Return dtFrom
    End Function

    Private Function GetLastDayOfMonth(ByVal dtDate As DateTime) As DateTime
        Dim dtTo As New DateTime(dtDate.Year, dtDate.Month, 1)
        dtTo = dtTo.AddMonths(1)
        dtTo = dtTo.AddDays(-(dtTo.Day))
        Return dtTo
    End Function

'if you put code like:
GetFirstDayOfMonth("2010-05-05") ' It will return = 2010-05-01
GetLastDayOfMonth("2010-05-05") ' It will return = 2010-05-31

Reff: http://redsouljaz.com/2010/06/03/get-first-day-of-the-month-and-last-day-of-the-month-in-vb-net/

By simplemsexchange Posted in VB.NET

Passing a Multi-value parameter to the ReportViewer control using VB

Private Sub SetReportParameters()
‘Set Processing Mode
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
ReportViewer1.AsyncRendering = False
‘ Set report server and report path
ReportViewer1.ServerReport.ReportServerUrl = New Uri(Session(“ReportServerUrl”).ToString())
ReportViewer1.ServerReport.ReportPath = Session(“ReportPath”).ToString() + Session(“SSRSReportName”).ToString()

‘ReportParameterInfoCollection(parameters = ReportViewerViewReport.ServerReport.GetParameters())

Dim paramList As New Generic.List(Of ReportParameter)
Dim pInfo As ReportParameterInfoCollection
pInfo = ReportViewer1.ServerReport.GetParameters()
If Not pInfo(“AccountID”) Is Nothing Then
paramList.Add(New ReportParameter(“AccountID”, Session(“AccountID”).ToString(), True))
End If

If Not pInfo(“LST_TXT_IRPARTNERS”) Is Nothing Then
Dim param As ReportParameter = New ReportParameter(“LST_TXT_IRPARTNERS”)
Dim p1 As String = Session(“SelectedIRPartners”).ToString()
Dim p2() As String = p1.Split(“,”)
param.Values.AddRange(p2)
paramList.Add(param)
‘paramList.Add(New ReportParameter(“LST_TXT_IRPARTNERS”, Session(“SelectedIRPartners”).ToString(), True))
End If

ReportViewer1.ServerReport.SetParameters(paramList)

‘ Process and render the report
ReportViewer1.ServerReport.Refresh()

By simplemsexchange Posted in VB.NET