|
-
Oct 24th, 2001, 06:49 AM
#1
Thread Starter
Fanatic Member
Creating Dynamic Strings
I wish to create a dynamic string in my program so that it can not be read in the compiled code. In other words I want to display a msgbox that states "The Sky is Blue" but I do not want the phrase "The Sky is Blue" to be found anywhere in the compiled form of my program.
What is the best way of doing this?
Thanks
-
Oct 24th, 2001, 06:56 AM
#2
Addicted Member
Well, there is a way. I'm not sure if it's the best way. It'll be a lil tedious.
You can write a string like this : -
msgbox chr(72) + chr(67) etc etc
Knowledge is static .... understanding is Dynamic
-
Oct 24th, 2001, 07:02 AM
#3
Conquistador
If you want to use ^^^ this method, to easily find out all the Chr codes, just use this:
VB Code:
Private Sub Form_Load()
Text1.Text = ReturnChars("This is an example in VB")
'MsgBox Chr(84) & Chr(104) & Chr(105) & Chr(115) & Chr(32) & Chr(105) & Chr(115) & Chr(32) & Chr(97) & Chr(110) & Chr(32) & Chr(101) & Chr(120) & Chr(97) & Chr(109) & Chr(112) & Chr(108) & Chr(101) & Chr(32) & Chr(105) & Chr(110) & Chr(32) & Chr(86) & Chr(66)
End Sub
Function ReturnChars(str As String) As String
For i = 1 To Len(str)
curpos = Mid(str, i, 1)
ReturnChars = ReturnChars & "Chr(" & Asc(curpos) & ") & "
Next
ReturnChars = Left(ReturnChars, Len(ReturnChars) - 2) 'Get rid of trailing amphersand
End Function
Then insert the result into your code...
-
Oct 24th, 2001, 07:03 AM
#4
PowerPoster
Store the string in a coded format and decode it when you wish to display it.
Gentile or Jew,
O you who turn the wheel and look to windward,
Consider Phlebas, who was once handsome and tall as you...
-
Oct 24th, 2001, 08:43 AM
#5
Thread Starter
Fanatic Member
Brain Freeze...
I need to assign 72,101,108,108,111,32,77,111,109 to the array mystr. I can use the code below
Code:
Dim mystr(8) As Integer
mystr(0)=72
mystr(1)=101
mystr(2)=108
mystr(3)=108
mystr(4)=111
mystr(5)=32
mystr(6)=77
mystr(7)=111
mystr(8)=109
But isn't there a way to initialize the array at design time all on one line? I know I can do this but I just cannot remember how.
-
Oct 24th, 2001, 11:40 AM
#6
Thread Starter
Fanatic Member
There has to be a better way...
This is what I came up with to get a msgbox to read "This program was only meant to be a demo." There must be a better way of doing this than what I am doing now. It just seems like this a lot of work just for one string how would I do multiple strings?
Is a resource file with a string table better? How secure is that resource file?
Code:
Option Explicit
Sub Main()
Dim MyStr() As Variant
MyStr = Array(84, 104, 105, 115, 32, 112, 114, 111, 103, 114, 97, 109, 32, 119, 97, 115, _
32, 111, 110, 108, 121, 32, 109, 101, 110, 116, 32, 116, 111, 32, 98, 101, _
32, 97, 32, 100, 101, 109, 111, 46)
Call MsgBox(GetString(MyStr))
End Sub
Public Function GetString(InputString As Variant) As String
Dim i As Integer
For i = LBound(InputString) To UBound(InputString)
GetString = GetString & Chr(InputString(i))
Next i
End Function
Thanks for the help again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|