Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Edit boxes in Delphi 7SE

Featured Replies

Fixed the first problem now I just have this question:

 

 

 

Also, how would I go about separating characters in an edit box? The user inputs a sentence, and I need to assign each letter to a variable as a number, so I can output that sentence but using a simple encryption I will change the letters so it is x letters forward or backward.

 

EG: 'hello' 3 letters forward will become 'jhoor', 'jhoor' 3 letters backward will be 'hello'.

 

 

 

I have a scrollbar that I use to set the variable 'key' and will just add 'key' to each letter, then add an if statement 'if it is over 26, then take away 26.'

 

 

 

 

 

 

 

(old post)>>This is in Delphi 7SE

 

 

 

if encoderadiobtn.Checked = true then

   encode;



 if decoderadiobtn.Checked = true then

   decode;



 if encoderadiobtn.Checked = false and decoderadiobtn.Checked = false then

   MessageDlg('Please choose encode or decode' , mtError, [mbOk], 0,);

 

It is part of a start button procedure

 

 

 

It compiles and runs fine, except when I click start with them both unchecked the error doesn't come up when it should, encode runs the procedure and the message, (it should just run the procedure) and decode runs the procedure like it should.

 

 

 

What I want it to do, is display the message if none are checked, run the encode procedure if it is checked, and the decode procedure if it is checked.

 

 

 

 

 

I am sure this is something really stupid that I overlooked, but I have been trying to get this simple thing to work for about 20 minutes.

 

 

 

Can anybody tell me what I am doing wrong?

You might want to make one of the two radio buttons checked at design time. Set the Checked property of, say, EncodeRadioBtn, to True, then you can remove your last IF entirely.

 

 

 

Alternatively, try this:

 

if (not EncodeRadioBtn.Checked) and (not DecodeRadioBtn.Checked) then

 

MessageDlg('Please choose Encode or Decode.', mtError, [mbOk], 0)

 

else if EncodeRadioBtn.Checked then

 

Encode

 

else

 

Decode;

 

 

 

{ other code here }

 

IF/ELSE IF/ELSE allows you to decide one action to execute according to the first condition that is met, then jump to the {other code here}. This would eliminate your code path problem.

 

 

 

P.S. It seems to me that you retyped the code into this thread and didn't copy-paste. The MessageDlg line does not compile. Your current code seems to be:

 

if encoderadiobtn.Checked = true then

 

encode;

 

 

 

if decoderadiobtn.Checked = true then

 

decode;

 

 

 

if encoderadiobtn.Checked = true and decoderadiobtn.Checked = false then

 

MessageDlg('Please choose encode or decode' , mtError, [mbOk], 0,); { Syntax error: Expression expected before ) }

vaporeon-sig.png
  • Author
You might want to make one of the two radio buttons checked at design time. Set the Checked property of, say, EncodeRadioBtn, to True, then you can remove your last IF entirely.

 

 

 

I got it to work just by putting encoderadiobtn.checked = true etc in brackets, but that is much better.

 

 

 

Also, how would I go about separating characters in an edit box? The user inputs a sentence, and I need to assign each letter to a variable as a number, so I can output that sentence but using a simple encryption I will change the letters so it is x letters forward or backward.

 

EG: 'hello' 3 letters forward will become 'jhoor', 'jhoor' 3 letters backward will be 'hello'.

 

 

 

I have a scrollbar that I use to set the variable 'key' and will just add 'key' to each letter, then add an if statement 'if it is over 26, then take away 26.'

 

 

 

BTW I did copy and paste the code in, some versions of delphi have slightly different syntax than others. What I have written compiled fine with delphi 7SE, but if I wanted to compile it with delphi 5 then i would have to change it to

 

 if encoderadiobtn.Checked := true then

     encode;

 

It doesn't compile without that colon.

you can eliminate your "if greater than 26 then take away 26" line by going like this, if you so desire ...

 

 

 

although i don't know the syntax of the language you're using

 

 

 

function encrypt(char c)

 

let x = getNumberFromLetter© // if c = 'a' then x = 1

 

x += key;

 

return getLetterFromNumber( mod(x,26) ) // if input = 5, returns 'e'

 

end function

 

 

 

http://en.wikipedia.org/wiki/Modulo_operation

 

 

 

=)

Mastermule52.png

The refuge that you built to flee that places that you've come to fear the most ... is the place that you have come to fear the most.

Operator - http://www.heartunit.org

Council - http://z8.invisionfree.com/skillaz

Moderator - http://forum.meebo.com

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.