Friday, November 11, 2011

cs 402 lecture 3

Regular Expression (RE)
a* and a+ are the regular expressions of the Language L1 and L2
Recursive Regular Expressions :

Step 1 : Every letter of sigma E including null string is a regular expression.
Step 2 : If r1 and r2 are regular expressions then
i (r1)
ii r1 r2
iii r1+r2
iv r1* 
are also regular expressions.
Step 3: Nothing else is a regular expression.

Express any language in short way  as regular expressions.

One language has more than one regular expressions but one regular expression can make only one language.

CS402 Lecture 2

Automaton :
The procedure to achieve the specific goal or task, according to our requirements.
1. Finite Automaton :
Possibilities are limited and created by us. Just like green light for go in the signal and red to stop in controlling traffic. And the given specific time to stop and start of each traffic.
Palindrome Language: 
The feature of this language is that it can be define with or without null string (Lamda)
String cannot be change if it is written in reverse order. And the line draws and shows the symmetry if read from both directions i.e aba
Even Length  String (middle line symmetric)
Odd Length  String (middle letter symmetric with same length)
If we combine two palindrome strings it create another palindrome.

Even Even Language:

Kleene Star closure
denoted by E* (Sigma star)
All concatenation of letters  and null string
Result will be in the strings two or more strings concatenate  result will be in between the string.

Plus operator :

It is just like kleene star but we cannot add null string by self in the plus operator

Recursive definition of languages :

The following steps are used to describe recursive languages.
1.some basic words are specified in the language
2. rules for constructing more words are defined in the language
3. no strings except those constructed above are allowed in the language



Tuesday, September 27, 2011

AutoComplete ComboBox in VB.Net

http://www.codeproject.com/KB/cpp/autocomplete_combobox.aspx


Private Sub cboName_Leave(ByVal sender As Object, ByVal e As System.EventArgs) 
                                                            Handles cboName.Leave
    Dim recRowView As DataRowView
    Dim recName As DB.tblNameRow

    AutoCompleteCombo_Leave(cboName)

    'OPTIONAL: Now you can  do some extra handling if you want


    'Get the Selected Record from my Data Bound Combo (Return Type is DataRowView)

    recRowView = cboName.SelectedItem
    If recRowView Is Nothing Then Exit Sub

    'Display the Name Info (Row Type comes from my bound Dataset)

    recName = recRowView.Row
    lblAccountNum.Text = recName.AccountNum
    lblCompanyName.Text = recName.CompanyName

End Sub

Private Sub cboName_KeyUp(ByVal sender As Object, 
              ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboName.KeyUp

    AutoCompleteCombo_KeyUp(cboName, e)

End Sub


Public Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs)
    Dim sTypedText As String
    Dim iFoundIndex As Integer
    Dim oFoundItem As Object
    Dim sFoundText As String
    Dim sAppendText As String

    'Allow select keys without Autocompleting

    Select Case e.KeyCode
        Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down
            Return
    End Select

    'Get the Typed Text and Find it in the list

    sTypedText = cbo.Text
    iFoundIndex = cbo.FindString(sTypedText)

    'If we found the Typed Text in the list then Autocomplete

    If iFoundIndex >= 0 Then

        'Get the Item from the list (Return Type depends if Datasource was bound 

        ' or List Created)

        oFoundItem = cbo.Items(iFoundIndex)

        'Use the ListControl.GetItemText to resolve the Name in case the Combo 

        ' was Data bound

        sFoundText = cbo.GetItemText(oFoundItem)

        'Append then found text to the typed text to preserve case

        sAppendText = sFoundText.Substring(sTypedText.Length)
        cbo.Text = sTypedText & sAppendText

        'Select the Appended Text

        cbo.SelectionStart = sTypedText.Length
        cbo.SelectionLength = sAppendText.Length

    End If

End Sub


Public Sub AutoCompleteCombo_Leave(ByVal cbo As ComboBox)
    Dim iFoundIndex As Integer

    iFoundIndex = cbo.FindStringExact(cbo.Text)

    cbo.SelectedIndex = iFoundIndex

End Sub


TEXTBOX AUTOCOMPLETE IN VB.NET.avi

http://youtu.be/YbzQbbQJQGg

DataTable.Select Method

[Visual Basic] 
Private Sub GetRowsByFilter()
    
    Dim customerTable As DataTable
    customerTable = new DataTable( "Customers" )

    ' Add columns
    customerTable.Columns.Add( "id", GetType(Integer) )
    customerTable.Columns.Add( "name", GetType(String) )

    ' Set PrimaryKey
    customerTable.Columns("id").Unique = true
    customerTable.PrimaryKey = new DataColumn() { customerTable.Columns("id") }

    ' add ten rows
    Dim id As Integer
    For id = 1 To 10
        customerTable.Rows.Add( _
            new object() { id, string.Format("customer{0}", id) } )
    Next id
    customerTable.AcceptChanges()

    ' add another ten rows
    For id = 11 To 20
        customerTable.Rows.Add( _
            new object() { id, string.Format("customer{0}", id) } )
    Next id

    Dim strExpr As String
    Dim strSort As String
    
    strExpr = "id > 5"
    ' Sort descending by CompanyName column.
    strSort = "name DESC"
    ' Use the Select method to find all rows matching the filter.
    Dim foundRows As DataRow() = _
        customerTable.Select( strExpr, strSort, DataViewRowState.Added )
    
    PrintRows( foundRows, "filtered rows")

    foundRows = customerTable.Select()
    PrintRows( foundRows, "all rows")
End Sub

Private Sub PrintRows( rows() As DataRow, label As String)
    Console.WriteLine( "\n{0}", label )
    If rows.Length <= 0 Then
        Console.WriteLine( "no rows found" )
        Exit Sub
    End If
    Dim r As DataRow
    Dim c As DataColumn
    For Each r In rows
        For Each c In r.Table.Columns
            Console.Write( "\t {0}", r(c) )
        Next c
        Console.WriteLine()
    Next r
End Sub

Visual Basic .NET Samples

http://www.xmlfox.com/VBsamples.htm#11

  • Convert Excel spreadsheet to PDF in .NET application
  • DataGridView Combo column (extended combobox)
  • DataGridView Numeric Column
  • .Net DataGrid combobox. Auto-fill and Dictionary.
  • Auto-fill combo box
  • .Net DataGrid Simple Sample.
  • Remove duplicates from an array
  • .Net XP DataGrid Button column Style.
  • .Net DataGrid Memo column Style.
  • .Net DataGrid DateTimePicker column Style.
  • How to Trap the Tab Key in a .NET Control?
  • How to format a datagrid column using a Date/Time format? How to update data in the column?
  • How to format a datagrid column using a Numeric format? How to update data in the column?
  • How to mask the data in a DataGrid Data column? How to mask the phone number (SSN, IP address) data?
  • How to draw a line in .NET? Line Control for .NET
  • autocomplete

    http://www.codeproject.com/KB/cpp/autocomplete_combobox.aspx

    combobox autocomplete - DROPDOWNLIST

    Bernie,

    To give me the idea, can you try if this is what you mean, you have to set
    the combobox to the normal dropdown however set that dropdownliststyle to
    true. I did not test it real deep, hower got the idea that it was working.

    \\\
    Private DropDownListStyle As Boolean
    Private Sub combobox1_KeyUp(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
            Dim cbo As ComboBox = DirectCast(sender, ComboBox)
            Select Case e.KeyCode
                Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete,
    Keys.Down
                    Return
            End Select
            Dim ComboBoxText As String = cbo.Text
            Dim FirstFound As Integer = cbo.FindString(ComboBoxText)
            If FirstFound >= 0 Then
                Dim FirstFoundItem As Object = cbo.Items(FirstFound)
                Dim FirstFoundText As String = cbo.GetItemText(FirstFoundItem)
                cbo.Text = FirstFoundText
                cbo.SelectionStart = ComboBoxText.Length
                cbo.SelectionLength = cbo.Text.Length
            Else
                If DropDownListStyle = True Then
                    cbo.Text = cbo.Text.Substring(0, cbo.Text.Length - 1)
                    cbo.SelectionStart = cbo.Text.Length
                End If
            End If
    End Sub
    ///

    Vb.net Tips and tricks

    http://www.bobpowell.net/

    Autocomplete text box in VB.net

    TextBox.AutoCompleteMode Property


    http://msdn.microsoft.com/en-us/library/chff42zw#Y0

    Friday, September 16, 2011

    Hp Printers


    Thursday, August 25, 2011











    ALTER TRIGGER [DEFINITIONS].[CLASSIFICATIONS_INS] ON [DEFINITIONS].[CLASSIFICATIONS]
    FOR UPDATE
    AS
    BEGIN
    --IF TRIGGER_NESTLEVEL() > 1
    -- RETURN
    UPDATE DEFINITIONS.CLASSIFICATIONS
    SET UPDATE_DATE=GETDATE(), UPDATE_USER=DIARY.fn_CURRENT_USER(@@SPID),UPDATE_TERMINAL=HOST_NAME()
    FROM DEFINITIONS.CLASSIFICATIONS C
    INNER JOIN INSERTED I ON C.CLASSIFICATION_ID=I.CLASSIFICATION_ID
    END


    ALTER TRIGGER [DEFINITIONS].[CLASSIFICATIONS_UPD] ON [DEFINITIONS].[CLASSIFICATIONS]
    FOR UPDATE
    AS
    BEGIN
    --IF TRIGGER_NESTLEVEL() > 1
    -- RETURN
    UPDATE DEFINITIONS.CLASSIFICATIONS
    SET UPDATE_DATE=GETDATE(), UPDATE_USER=DIARY.fn_CURRENT_USER(@@SPID),UPDATE_TERMINAL=HOST_NAME()
    FROM DEFINITIONS.CLASSIFICATIONS C
    INNER JOIN INSERTED I ON C.CLASSIFICATION_ID=I.CLASSIFICATION_ID
    END

    After diagnose I found the error in the bold text.
    I change it for the insert trigger FOR INSERT and solved the problem

    Saturday, August 6, 2011

    Windows 7 professional Key

    After installation of Service Pack 1
    I Activated with the following key
    PX786-76P9H-PC9W9-8GK8Y-Y2WWH


    Microsoft Windows 7 Professional 64-bit (English) - DreamSpark - Download  
    Extended Access Guarantee (24 months)Extended Access Guarantee (24 months) - Included 
    24 months of access to your download and/or key. This does not extend the duration of time-limited licenses (if applicable). 
    Expires 2014-10-03
    Product Key: XHVMK-W2VHG-QGMHM-8K7Y3-HJJFB
    Agreement Number: 1203690345

    Wednesday, January 26, 2011

    Fix Error in MS SQL to link user

    SQL SERVER – FIX : Error 15023: User already exists in current database.
    February 15, 2007 by pinaldave
    Error 15023: User already exists in current database.

    1) This is the best Solution.
    First of all run following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan.
    USE YourDB
    GO
    EXEC sp_change_users_login 'Report'
    GO

    Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist. In following example ‘ColdFusion’ is UserName, ‘cf’ is Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in sysxlogins.
    USE YourDB
    GO
    EXEC sp_change_users_login 'Auto_Fix', 'ColdFusion', NULL, 'cf'
    GO

    Run following T-SQL Query in Query Analyzer to associate login with the username. ‘Update_One’ links the specified user in the current database to login. login must already exist. user and login must be specified. password must be NULL or not specified
    USE YourDB
    GO
    EXEC sp_change_users_login 'update_one', 'ColdFusion', 'ColdFusion'
    GO

    2) If login account has permission to drop other users, run following T-SQL in Query Analyzer. This will drop the user.
    USE YourDB
    GO
    EXEC sp_dropuser 'ColdFusion'
    GO

    Create the same user again in the database without any error.

    Stored Procedure 1:
    /*Following Stored Procedure will fix all the Orphan users in database
    by mapping them to username already exist for user on server.
    This SP is required when user has been created at server level but does
    not show up as user in database.*/
    CREATE PROCEDURE dbo.spDBA_FixOrphanUsers
    AS
    DECLARE @username VARCHAR(25)
    DECLARE GetOrphanUsers CURSOR
    FOR
    SELECT UserName = name
    FROM sysusers
    WHERE issqluser = 1
    AND (sid IS NOT NULL
    AND sid <> 0x0)
    AND SUSER_SNAME(sid) IS NULL
    ORDER BY name
    OPEN GetOrphanUsers
    FETCH NEXT
    FROM GetOrphanUsers
    INTO @username
    WHILE @@FETCH_STATUS = 0
    BEGIN
    IF @username='dbo'
    EXEC sp_changedbowner 'sa'
    ELSE
    EXEC sp_change_users_login 'update_one', @username, @username
    FETCH NEXT
    FROM GetOrphanUsers
    INTO @username
    END
    CLOSE GetOrphanUsers
    DEALLOCATE GetOrphanUsers
    GO

    Stored Procedure 2:
    /*Following Stored Procedure will fix all the Orphan users in database
    by creating the server level user selecting same password as username.
    Make sure that you change all the password once users are created*/
    CREATE PROCEDURE dbo.spDBA_FixOrphanUsersPassWord
    AS
    DECLARE @username VARCHAR(25)
    DECLARE @password VARCHAR(25)
    DECLARE GetOrphanUsers CURSOR
    FOR
    SELECT UserName = name
    FROM sysusers
    WHERE issqluser = 1
    AND (sid IS NOT NULL
    AND sid <> 0x0)
    AND SUSER_SNAME(sid) IS NULL
    ORDER BY name
    OPEN GetOrphanUsers
    FETCH NEXT
    FROM GetOrphanUsers
    INTO @username
    SET @password = @username
    WHILE @@FETCH_STATUS = 0
    BEGIN
    IF @username='dbo'
    EXEC sp_changedbowner 'sa'
    ELSE
    EXEC sp_change_users_login 'Auto_Fix', @username, NULL, @password
    FETCH NEXT
    FROM GetOrphanUsers
    INTO @username
    END
    CLOSE GetOrphanUsers
    DEALLOCATE GetOrphanUsers
    GO

    Stored Procedure 3:
    ----Following Stored Procedure will drop all the Orphan users in database.
    ----If you need any of those users, you can create them again.
    CREATE PROCEDURE dbo.spDBA_DropOrphanUsers
    AS
    DECLARE @username VARCHAR(25)
    DECLARE GetOrphanUsers CURSOR
    FOR
    SELECT UserName = name
    FROM sysusers
    WHERE issqluser = 1
    AND (sid IS NOT NULL
    AND sid <> 0x0)
    AND SUSER_SNAME(sid) IS NULL
    ORDER BY name
    OPEN GetOrphanUsers
    FETCH NEXT
    FROM GetOrphanUsers
    INTO @username
    WHILE @@FETCH_STATUS = 0
    BEGIN
    IF @username='dbo'
    EXEC sp_changedbowner 'sa'
    ELSE
    EXEC sp_dropuser @username
    FETCH NEXT
    FROM GetOrphanUsers
    INTO @username
    END
    CLOSE GetOrphanUsers
    DEALLOCATE GetOrphanUsers
    GO

    Monday, January 17, 2011

    DIABETIC

    FINALLY GOOD NEWS FOR ALL DIABETICS

    A woman (65) was diabetic for the last 20+ years and was taking insulin twice a day, she used the below mentioned homemade concoction for a fortnight and is now absolutely free from diabetes. She now eats normal food including sweets ...........................
    Doctors have advised her to stop insulin and any other blood sugar controlling drugs.
    I request you please circulate the email below to as many people as you can to enable them take maximum benefit from it.

    AS RECEIVED :
    DR. TONY ALMEIDA ( Bombay Kidney Speciality expert ) made the extensive experiments with perseverance and patience and discovered a successful treatment for diabetes. Nowadays a lot of people, old men & women in particular suffer a lot due to Diabetes.

    Ingredients:
    1 - Wheat flour 100 gm
    2 - Gum(of tree) (gondh) 100 gm
    3 - Barley 100 gm
    4 - Black Seeds (kalunji) 100 gm

    Method of Preparation - Put all above ingredients in 5 cups of water.
    Boil for 10 minutes and allow to cool down. Thereafter, filter out the solids and preserve the water in a glass jug or glass bottle..

    How to use:
    Drink one small cup of this water daily, early morning on empty stomach.
    Continue for 7 days. Second week, repeat the same but on alternate days. With the two-week treatment you will be amazed to find that you have become normal and are able to eat normal food without problem.

    Note: Kindly spread this good news so that others can benefit from it.
    SPB MESSAGE
    SINCE THESE ARE ALL NATURAL INGREDIENTS, TAKING THEM IS NOT HARMFUL. SO, THOSE WHO ARE SCEPTICAL ABOUT THIS TREATMENT MAY STILL TRY IT WITHOUT ANY HARM. WORST CASE SCENARIO WILL BE THAT YOU REMAIN STILL THE SAME AS YOU WERE BEFORE.