Hi Erum
glad to be useful
please focus your mind before on this
an attempt to analyze the issue that the program must solve.
structure of the program what does your program? as you have said in previous posts
1. it takes 2 parameters (pH and Temperature in FAHRENHEIT)
2. it outputs informations as text on the screen on the basis of 2 parametersmoreover you should think that you manage
3. the input from keyboard and/or mouse
4. and the output to the screen
5. and the storage of the informations (inner to the program or outer in files)
6. and an interface for user (only text, an ASCII windowed, a graphic windowed)going deeper
1. you need 2 variables for the 2 parameters... the type of variable used depens of type of data to get from keyboard.
see here for more info
http://qb64.org/wiki/Variable_TypesFrom your code posted before I can think that pH has a range from 1 to 14 with decimal so in QB64 we can use single declared with
! suffix or none suffix, while for temperature there is a range from 32 or less to 134 , but you manage only integer, so you can use an integer variable declared with suffix %
2. in your code you share analysis of value pH and Temperature with Output to screen.
If you want a more flexible code it is useful to separate these two performances. So tomorrow you can modify only the part of program that you must adapt to new needs and not following the line of flow of the program in chained instructions.
2.1
you can make a grid of pH values and Temperature to manage the various cases... (if you do this on you code you can see that the
case temperature T >= 32 AND T <= 113 is not managed in the range pH p > 8.4 AND p <= 14 so in this case your program
stucks
2.2 all strings for output must be loaded into an array of strings (the string is text between 2 ") (array is a set of variables of the same type and with the same name and with an index to distinguish one from another one) see here for more informations
http://qb64.org/wiki/Arrays3. input from keyboard
3.1 you can use old INPUT (a semi editor of Qbasic) and you must control the values typed from user (as you do in your code)
3.2 or the INKEY$ to accept only digit and . for get pH and temperature values
3.3 or you can use the powerful _KEYHIT of QB64 at the same way of INKEY$ for your goal
3.4 or you can use mouse (_MOUSEBUTTON(1) or _MOUSEBUTTON(2) or _MOUSEWHEEL) to set input for pH and Temperature
3.5 or you can use mouse for interaction of user with a structured interface made in text or graphic mode
4. output to the screen
4.1 choose the screen mode
if it is good for you an interface only text or window text based (ASCII screen) you can use SCREEN 0 and use 8 colors for
paper color (background 0-7) and 31 ink colors (foreground 0-31, after 15 color is blinking)
but if you prefer the graphic mode you can have so many graphic options to manage and use
4.2 choose the interface that you must build it for using in your program see point 6 (for now you have used a line text interface)
5. storage of informations
5.1 informations stored as strings into the program (the way that you have coded)
5.2 informations stored as DATA into the program (blocks of DATA) see here for more info
http://qb64.org/wiki/DATA 5.3 informations stored as TXT file that you load in the program in a set of variable of type of string called Array (OPEN FOR
INPUT) see here for more info
http://qb64.org/wiki/OPEN. The real advantage to code in this way is that you can
change or adapt the text editing the file with an editor of text from Notepad to OpenOffice Writer and you program gains
adjourned informations without so many changes to the code.
6. an user interface
6.1 a line text of interface (that you have coded)
6.2 a text interface with prefixed space of screen for different actions
6.3 a text ASCII interface with inputbox, button, listbox
6.4 a graphic interface with inputbox, button, listbox
Good work and good luck
PS: all the answers that you have got until now is how to make a listbox in ASCII mode or in Graphic mode.
Wrong :-) before the last Bplus 's post!