Hello im trying to create my first software :)

this is what im wanting to do

There is a text box with 1 command button

and inside the text box will store arrays

0-25

for example

cypher(0) = "0"
cypher(1) = "1"
cypher(2) = "2"
cypher(3) = "3"
cypher(4) = "4"
cypher(5) = "5"
cypher(6) = "6"
cypher(7) = "7"
cypher(8) = "8"
cypher(9) = "9"
cypher(10) = "10"
cypher(11) = "11"
cypher(12) = "12"
cypher(13) = "13"
cypher(14) = "14"
cypher(15) = "15"
cypher(16) = "16"
cypher(17) = "17"
cypher(18) = "18"
cypher(19) = "19"
cypher(20) = "20"
cypher(21) = "21"
cypher(22) = "22"
cypher(23) = "23"
cypher(24) = "24"
cypher(25) = "25"

Now each number represents a letter for example

0=A
1=B
2=C

and so forth

How would i get it to where whatever the person types in the submit button it will calculate there text and convert it from numbers to the specified letter

now indeed im very VERY VERY new to vb as tho im trying to learn it

But making it say

if cypher(0) = "0" then
msgbox("A")
endif

Would be rather annoying so if im correct to add all of the strings together wouldnt i type?

If cypher(0 - cypher(25)) Then

Now the question is how would i make it understand where cypher 0 is actually A?


Any help would be much appreciated

Recommended Answers

All 3 Replies

Okay, I think you are over thinking this...

Now, if I understand you correctly you want the numbers (0 to 25) to represent A to Z. So when the user enters any number from 0 to 25, clicks the button, you show the letter from A to Z.

Private Sub Command1_Click()
If IsNumeric(Text1.Text) = False Then
  MsgBox "You must enter a number from 0 to 25.", vbOkOnly + vbInformation, "Incorrect Input"
  Exit Sub
End If
If CInt(Text1.Text) >= 0 And CInt(Text1.Text) <= 25 Then
  MsgBox "The letter is " & CypherArray(CInt(Text1.Text)), vbOkOnly, "Good Input"
Else
  MsgBox "You must enter a number from 0 to 25.", vbOkOnly + vbInformation, "Incorrect Input"
End If
Exit Sub

Where

Option Explicit

Dim CypherArray(0 To 25) As String

Private Sub Form_Load()

CypherArray(0) = "A"
CypherArray(1) = "B"
'...
End Sub

Good Luck

Hi thankyou now it is what i need but the problem is

if i type 01234 it will only calculate 4 and not the rest if it did it would display

abcde

Do u have any idea on how i go about this

Problem with the logic you are trying to implement...

You do not have a delimeter to tell the difference between characters so if I entered 252423... do you see...

You need to have a delimeter like a comma 0,1,2,3,4 or 25,24,23 or a space or dash or something because any type of loop that iterates from the first character to the last character will always give you the representations of 0 through 9. Or you can just have the user enter one character at a time and then output what they enter into another textbox.

So, if you use a delimeter then you will need to look at...

Arrays (Dim MyStringArray() As String)
Split Function (MyStringArray = Split(Text1.Text, ",")
UBound
LBound
For Loop
Concatination (Text2.Text = Text2.Text & ...)


Good Luck

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.