before i try my idea (1 Viewer)

murray83

Games Collector
Local time
Today, 05:40
Joined
Mar 31, 2017
Messages
728
question i want to ask before i dive into something.

can/could you have text box on a form update in real time when you are typing and have it dlookup to a table to translate what your typing

for example in the table would have the alphabet upper and lowercase

the form would have two text boxes one which you type in and the second which would have the dlookup which would check each character you put in the first text box and find its corresponding one in the table

or am i just chasing rainbows.

thanks all for looking
 

murray83

Games Collector
Local time
Today, 05:40
Joined
Mar 31, 2017
Messages
728
shall check it out, thanks for the pointer
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:40
Joined
May 21, 2018
Messages
8,525
question i want to ask before i dive into something.

can/could you have text box on a form update in real time when you are typing and have it dlookup to a table to translate what your typing

for example in the table would have the alphabet upper and lowercase

the form would have two text boxes one which you type in and the second which would have the dlookup which would check each character you put in the first text box and find its corresponding one in the table

I read this differently, like it is some kind of translation (cypher). You have a table A-Z and each record has a corresponding character or number

A X
B T
C V

If I type ABC I should see XTV. If that is correct interpretation it would be doable using the on change event of the first textbox.
 

murray83

Games Collector
Local time
Today, 05:40
Joined
Mar 31, 2017
Messages
728
I read this differently, like it is some kind of translation (cypher). You have a table A-Z and each record has a corresponding character or number

A X
B T
C V

If I type ABC I should see XTV. If that is correct interpretation it would be doable using the on change event of the first textbox.

YES that is what i was after, but could it work for a whole sentence of text ??

say you typed in "hello world" and then the second text box out putted "ydool slofe"
 

isladogs

MVP / VIP
Local time
Today, 05:40
Joined
Jan 14, 2017
Messages
18,209
And I read it that you wanted to either change letters like a to á etc ...or translate words.
Whatever you are after, running code as each character is added can be very slow. I would use the after update event instead so your code only runs once.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:40
Joined
May 21, 2018
Messages
8,525
Is this case sensitive? The solution for case sensitive will be a little more complex than non case sensitive. Does Abc need to be Xtv? If so I would not store the actual letter but the ASCII decimal value.
http://www.asciitable.com/

TblConversion
Code:
  letterOneASCII
  letterTwoASCII

then instead of
A X
B T
C V
....
a x
b t
c v

I would store

65 88
66 84
67 86
...
97 120
98 116
99 118
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:40
Joined
May 21, 2018
Messages
8,525
This works for me using storing only the upper case ascii and then converting as needed for the lower. So my tblConversion looks like

Code:
convertID	ASCII_One	ASCII_Two
1	65	88
2	66	84
3	67	86
You would need to store 65-90 and its conversion.

Code:
Public Function ConvertString(myString As String) As String
  Dim I As Integer
  For I = 1 To Len(myString)
    ConvertString = ConvertString & GetLetter(Mid(myString, I, 1))
  Next I
End Function

Public Function GetLetter(Letter As String) As String
  Const TableName = "tblConversion"
  Const FldOne = "ASCII_One"
  Const FldTwo = "ASCII_Two"
  Dim IsLowerCase As Boolean
  Dim ascLetter As Long
  Dim convertASC As Long
  ascLetter = Asc(Letter)
  'Store only upper cases  lower case is between 97 and 122. Convert to upper and later convert back
  GetLetter = Letter
  If ascLetter > 96 And ascLetter < 123 Then
    IsLowerCase = True
    ascLetter = ascLetter - 32
  End If
  If ascLetter > 64 And ascLetter < 91 Then
    convertASC = DLookup(FldTwo, TableName, FldOne & " = " & ascLetter)
    If IsLowerCase Then convertASC = convertASC + 32
    GetLetter = Chr(convertASC)
  End If
End Function

here is a test

Code:
Public Sub TestIt()
  Debug.Print ConvertString("ABC abc 123 ABC")
End Sub
which prints
XTV xtv 123 XTV
Handles uppercase lower case and things not in the table.
 

Users who are viewing this thread

Top Bottom