Skip to content

Plz anybody convert my code from vb to c#

Shah Shishir

Asked Oct 2, 2008, 11:42 PM EDT2 answers
Share
LinkedInX
If txtPassword.Text = txtCpassword.Text Then

            Dim StrTempChar As String
            Dim i As Integer

            Dim MyPwd As String
            MyPwd = txtPassword.Text

            For i = 1 To Len(MyPwd)
                If Asc(Mid$(MyPwd, i, 1)) < 128 Then
                    StrTempChar = CType(Asc(Mid$(MyPwd, i, 1)) + 128, String)
                ElseIf Asc(Mid$(MyPwd, i, 1)) > 128 Then
                    StrTempChar = CType(Asc(Mid$(MyPwd, i, 1)) - 128, String)
                End If

                Mid$(MyPwd, i, 1) = Chr(CType(StrTempChar, Integer))
            Next i

            Conn.Open()
            Comm = New Data.SqlClient.SqlCommand
            Comm.Connection = Conn
            Comm.CommandType = Data.CommandType.Text
            Comm.CommandText = "Insert Into customer (Emailid,Password,Userid,Add1,State,City,Pin,Title,Fname,Lname,Gender,Dob,Mobile,Regidate) " & _
                " values('" & txtEmailid.Text & "','" & MyPwd & "','" & txtEmailid.Text & "','" & txtAdd1.Text & "','" & cmbState.SelectedItem.Text & "','" & txtCity.Text & "'," & txtPin.Text & ",'" & CmbTitle.SelectedItem.Text & "','" & txtFname.Text & "','" & txtLname.Text & "','" & cmbGender.SelectedItem.Text & "','" & BodDate.SelectedDate.Date & "'," & txtMobile.Text & ",'" & System.DateTime.Today & "')"
            Comm.ExecuteNonQuery()
            Conn.Close()

            Adpt = New Data.SqlClient.SqlDataAdapter("select * from customer", Conn)
            Dataset1 = New Data.DataSet
            Adpt.Fill(Dataset1, "customer")

            EmptyControls()
        Else
            'EmptyControls()
            lblMessage.Visible = True
            lblMessage.Text = "Try Again !.....Password and Confirm Password is not Match"
        End If



Thanks in advance
Plz solve my problem as early as possible
Shah Shishir

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    +1
    { if (txtPassword.Text == txtCpassword.Text) { string StrTempChar = null; int i = 0; string MyPwd = null; MyPwd = txtPassword.Text; for (i = 1; i <= Strings.Len(MyPwd); i++) { if (Strings.Asc(Strings.Mid(MyPwd, i, 1)) < 128) { StrTempChar = (string)Strings.Asc(Strings.Mid(MyPwd, i, 1)) + 128; } else if (Strings.Asc(Strings.Mid(MyPwd, i, 1)) > 128) { StrTempChar = (string)Strings.Asc(Strings.Mid(MyPwd, i, 1)) - 128; } Strings.Mid(MyPwd, i, 1) = Strings.Chr((int)StrTempChar); } Conn.Open(); Comm = new Data.SqlClient.SqlCommand(); Comm.Connection = Conn; Comm.CommandType = Data.CommandType.Text; Comm.CommandText = "Insert Into customer (Emailid,Password,Userid,Add1,State,City,Pin,Title,Fname,Lname,Gender,Dob,Mobile,Regidate) " + " values('" + txtEmailid.Text + "','" + MyPwd + "','" + txtEmailid.Text + "','" + txtAdd1.Text + "','" + cmbState.SelectedItem.Text + "','" + txtCity.Text + "'," + txtPin.Text + ",'" + CmbTitle.SelectedItem.Text + "','" + txtFname.Text + "','" + txtLname.Text + "','" + cmbGender.SelectedItem.Text + "','" + BodDate.SelectedDate.Date + "'," + txtMobile.Text + ",'" + System.DateTime.Today + "')"; Comm.ExecuteNonQuery(); Conn.Close(); Adpt = new Data.SqlClient.SqlDataAdapter("select * from customer", Conn); Dataset1 = new Data.DataSet(); Adpt.Fill(Dataset1, "customer"); EmptyControls(); } else { //EmptyControls() lblMessage.Visible = true; lblMessage.Text = "Try Again !.....Password and Confirm Password is not Match"; } }
    +1