Jump to content
Xtreme .Net Talk

jcrcarmo

Avatar/Signature
  • Posts

    32
  • Joined

  • Last visited

Everything posted by jcrcarmo

  1. Dear PlausiblyDamp, The tweaked code didn't work, but your literal translation of the code I posted worked out beautifuly. By the way, I will be more careful when I create new threads by paying attention to the correct subforum they are supposed to go to. Thank you very very much for your kind help and have a great day! Best regards, JC :)
  2. Hello folks, The transition from VB.Net 2005 to C# 2005 is not always a smooth proccess, even though the synthax is almost identical in some cases. The code below exemplifies a MS Access Database Backup routine I'm trying to tranlsate to C# 2005: --------------------------------------------------------------------------------------------------------- Private Sub BackupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackupToolStripMenuItem.Click Dim Time As String = Format(Now, " dddd dd-MM-yyyy à's' HH'h' mm'min' ss'seg'") Dim FileName As String = "myDB " & Time & ".mdb" Dim SavePath As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\myDB\Backups\" If Not My.Computer.FileSystem.DirectoryExists(SavePath) Then My.Computer.FileSystem.CreateDirectory(SavePath) My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath & "\myDB.mdb", SavePath & FileName, True) MsgBox("Backup performed succesfully. ", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "Ready") Else My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath & "\myDB.mdb", SavePath & FileName, True) MsgBox("Backup performed succesfully. ", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "Ready") End If End Sub --------------------------------------------------------------------------------------------------------- Can anyone help me out on this one? Thanks in advance! Best regards, JC :)
  3. Hi mskeel, Yes, I did learn VB way before I started learning C#. How did you guess that? hehehe. Anyway, I'm getting to love C# more and more for it's a more robust language and seems to be processed a lot faster by my machine. Thank you so much for your reply. I can't believe the solution was so simple... Just amazing! Now the code works just fine. Thanks a million! Bye for now, JC :)
  4. Locking all Controls on a Form - Solved! Your code works really well. Thanks for replying so quickly. JC :)
  5. Hi everybody, The following code runs fine util the commented lines. The debugger halts and sends me a message saying that "custView is a variable and is being used as a method". Can anyone shed some light on this? Thank you very much. Best regards, JC :) -------------------------------------------------------------------------- private void btnLogin_Click(object sender, EventArgs e) { System.Data.DataView custViewLogin = new System.Data.DataView(SASCRDataSet.tabUsers, "", "Login", System.Data.DataViewRowState.CurrentRows); System.Data.DataView custViewPassword = new System.Data.DataView(SASCRDataSet.tabUsers,"", "Password", System.Data.DataViewRowState.CurrentRows); int rowIndexLogin = custViewLogin.Find(this.txtUserName.Text); int rowIndexPassword = custViewPassword.Find(this.txtPassword.Text); if (rowIndexLogin == -1 || rowIndexPassword == -1) { MessageBox.Show("Usuário ou Senha inválida. \r" + "Por favor tente de novo. ", "Acesso negado ...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtPassword.Focus(); this.txtPassword.Text = ""; CTM = CTM + 1; if (CTM == TRYMAX) { MessageBox.Show("Você usou o nº máximo de tentativas \r" + " de login e está sendo desconectado \r" + " por motivos de segurança! ", "Acesso bloqueado ...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Application.Exit(); } } else { //---------------- This is where the problems starts--------------- this.UserRealName.Text = custViewLogin(rowIndexLogin)("UserRealName").ToString(); this.AccessRights.Text = custViewLogin(rowIndexLogin)("AccessRights").ToString(); //---------------- This is where the problems finishes--------------- Form frmMain = new frmMain(); frmMain.Show(); this.Hide(); } }
  6. Hi everybody, Greetings from Brazil. I'm new to C# and would really appreciate it if anyone could please help me translate the VB2005 code below to C#. The following code locks all TextBox and MaskedTextBox controls on a form. Thanks in advance. Best regards, JC :) Public Sub LockForm() On Error Resume Next Dim ctl As Control For Each ctl In Me.Controls If CType(ctl, TextBox).ReadOnly = False And CType(ctl, MaskedTextBox).ReadOnly = False Then CType(ctl, TextBox).ReadOnly = True CType(ctl, TextBox).BackColor = Color.White CType(ctl, MaskedTextBox).ReadOnly = True CType(ctl, MaskedTextBox).BackColor = Color.White End If Next End Sub
  7. Locking controls on a form - VB 2005 Greetings from Brazil! Here's a simple Public Sub that locks all TextBox and MaskedTextBox controls on a form, switching their ReadOnly property. Also, it keeps the controls BackColor white. I hope it helps: Public Sub LockForm() On Error Resume Next Dim ctl As Control For Each ctl In Me.Controls If CType(ctl, TextBox).ReadOnly = False And CType(ctl, MaskedTextBox).ReadOnly = False Then CType(ctl, TextBox).ReadOnly = True CType(ctl, TextBox).BackColor = Color.White CType(ctl, MaskedTextBox).ReadOnly = True CType(ctl, MaskedTextBox).BackColor = Color.White End If Next End Sub Public Sub UnlockForm() On Error Resume Next Dim ctl As Control For Each ctl In Me.Controls If CType(ctl, TextBox).ReadOnly = True And CType(ctl, MaskedTextBox).ReadOnly = True Then CType(ctl, TextBox).ReadOnly = False CType(ctl, TextBox).BackColor = Color.White CType(ctl, MaskedTextBox).ReadOnly = False CType(ctl, MaskedTextBox).BackColor = Color.White End If Next End Sub Best Regards, JC :)
×
×
  • Create New...