hi I need a code that allowed the user to enter 4 digit in the textbox then replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. then swap the first digit with the third and swap the second digit with the fourth. the result show in label
thks lot plz help

Recommended Answers

All 10 Replies

How about showing us what you've done first so we can take a look at it..

1st you start. you can take help from search engine. download code and try it.

Im completely new to vb ..im trying i got this far.........
Public Class frmEncryption

Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
Dim number As Integer
Dim result As Integer


If Val(txtenter.Text) < 0 Or
(IsNumeric(txtenter.Text) = False) Then
MessageBox.Show("Invalid Entry", "Input Error")
Exit Sub
End If

number = txtenter.Text


lblresult.Text = result.ToString


End Sub
End Class


im trying to figure out how to rplace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10.

..

okay this what i got
so far


it does work i jus need to show the result in label not in textbox

Public Class frmEncryption

Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click

Dim result As Integer
txtenter.Text = Encrypt(txtenter.Text)

If Val(txtenter.Text) < 0 Or
(IsNumeric(txtenter.Text) = False) Then
MessageBox.Show("Invalid Entry", "Input Error")
Exit Sub
End If


lblresult.Text = result.ToString
End Sub
Private Function Encrypt(ByVal strInput As String) As String
Dim i As Integer
Dim strDigit As String
Dim intDigit As Integer
Dim intDigits(3) As Integer

For i = 1 To 4
strDigit = Mid(strInput, i, 1)
intDigit = CInt(strDigit) + 7
intDigits(i - 1) = intDigit Mod 10
Next i

Encrypt = CStr(intDigits(2)) & CStr(intDigits(3)) & CStr(intDigits(0)) & CStr(intDigits(1))
End Function


End Class

anyone know a way that i can learn to code faster........any ideas ...like a book or somtihng if u do let me kno
thks

its VB.NET and not VB6.. All you have to learn is String Manipulation and their function like Text Replace, Mid, Left, Right...

You are referring to a label in a module. Add the form name where it is located -

lblresult.Text = result.ToString

'a Label has a caption and not text...

frmMain.lblresult.Caption = result.ToString

thks

Only a pleasure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.