Thursday 23 August 2012

Textbox Control with TEXT in background


It would be better to create a custom TextBox control,
but here is something quickly hard-coded to give you a idea.

Find what event gives you desired result etc......


For simple example make sure textbox1 tabindex is not 1

Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TextBox1.ForeColor = Color.LightSlateGray
TextBox1.Text = "Enter Search Criteria"
End Sub
Private Sub TextBox1_Leave(sender As System.Object, e As System.EventArgs) Handles TextBox1.Leave
If TextBox1.Text = "" Then
            TextBox1.ForeColor = Color.LightSlateGray
TextBox1.Text = "Enter Search Criteria"
End If
End Sub
Private Sub TextBox1_Enter(sender As System.Object, e As System.EventArgs) Handles TextBox1.Enter
If TextBox1.Text = "Enter Search Criteria" Then
TextBox1.Text = ""
TextBox1.ForeColor = Color.Black
End If
End Sub
End Class

Output::
 

Saturday 4 August 2012

convert number to words in Crystal Reports

convert number to words in Crystal Reports

  • Copy code and Paste in Formula Field.

numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :="Rupees ";
Amt := {txtRuppes.Text};
if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords := InWords + " " + towords(RmVal,0) + " crore"
else
if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";

Amt := Amt - Rmval * 10000000;
if Amt > 100000 then RmVal := truncate(Amt/100000);
if Amt = 100000 then RmVal := 1;
if RmVal >=1 then
InWords := InWords + " " + towords(RmVal,0) + " lakhs";

Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);
pAmt := (Amt - truncate(Amt)) * 100;
if pAmt > 0 then
InWords := InWords + " and " + towords(pAmt,0) + " paisa only"
else
InWords := InWords + " only";
UPPERCASE(InWords)

OutPut

Write XML in VB.net

Write XML in VB.net



Write XML in Vb.net Using Entity Data Model

Code for VB

Imports ProjectManager.ProjectManagerModel
Imports System.Xml

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim DataObj As Customer
        Dim Cust As String = txtCustCode.Text
        Using modelContext As New ProjectManagerEntities
                DataObj = modelContext.Customers.Where(Function(C) C.CustId = CDbl(Cust)).FirstOrDefault()
                txtCustCode.Text = DataObj.CustId.ToString
                txtCustAlias.Text = DataObj.Account.Alias
                txtCustName.Text = DataObj.CustName
        End Using
    End Sub

    Private Sub btnXML_Click(sender As System.Object, e As System.EventArgs) Handles btnXML.Click
        Dim DataObj As Customer
        Dim Cust As String = txtCustCode.Text
 

        Using modelContext As New ProjectManagerEntities

            DataObj = modelContext.Customers.Where(Function(C) C.CustId = CDbl(Cust)).FirstOrDefault()
            ' Create XmlWriterSettings.
            Dim settings As XmlWriterSettings = New XmlWriterSettings()
            settings.Indent = True
            ' Create XmlWriter.
            Using writer As XmlWriter = XmlWriter.Create("C:\Customer.xml", settings)
                ' Begin writing.
                writer.WriteStartDocument()
                writer.WriteStartElement("Customers") ' Root.
                writer.WriteStartElement("Customer")

                writer.WriteElementString("CustId", DataObj.CustId.ToString)
                writer.WriteElementString("CustAlias", DataObj.Account.Alias)
                writer.WriteElementString("CustName", DataObj.CustName)

                writer.WriteEndElement()

                ' End document.
                writer.WriteEndElement()
                writer.WriteEndDocument()
            End Using
        End Using

    End Sub



End Class


Output...