LB Booster
« Variable Number Of Rows Of Texboxes »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:24am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 veryhotthread  Author  Topic: Variable Number Of Rows Of Texboxes  (Read 2367 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Variable Number Of Rows Of Texboxes
« Reply #11 on: Apr 3rd, 2015, 8:32pm »

on Apr 3rd, 2015, 8:15pm, RNBW wrote:
You didn't say how to prevent it

Yes I did: I said I had made the modification (and others) in my version of the program; you need only have looked there.

Ideally you should also remove the WS_TABSTOP style bit because despite being read-only the header fields are still included in the tab order, which isn't particularly useful.

Anyway I said I wouldn't be contributing to this forum any more, so I'll retreat to my comfort zone again.

Richard.
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #12 on: Apr 3rd, 2015, 9:14pm »

Sorry, I didn't realise that you could alter earlier posted code insitu.

I'll look at your code.

I appreciate that you said you wouldn't be posting to this forum again, but I think I probably speak for all users and readers when I ask you to continue. Your experience and expertise is absolutely invaluable to us all.
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: Variable Number Of Rows Of Texboxes
« Reply #13 on: Apr 4th, 2015, 01:19am »

on Apr 3rd, 2015, 8:32pm, Richard Russell wrote:
Anyway I said I wouldn't be contributing to this forum any more, so I'll retreat to my comfort zone again.

Richard.


Confucius say:
A programmer must program, else he will no longer be a programmer wink
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #14 on: Apr 5th, 2015, 09:54am »

on Apr 1st, 2015, 10:38pm, RobM wrote:
Not sure I completely understand what you need but maybe you can modify this as needed. It uses API created textboxes in a graphics window that can be scrolled. In the program where I use this I also have it set to scroll with the mouse wheel via the WMliberty dll.

-----------------------------------------------------------
I had a quick look at your code when you first posted it and decided it wouldn't easily serve my purpose. However, I've just looked at it again today and I can see some very useful code there, which I will probably be able to make use of in the future. So thank you very much for your post.

Ray
User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Re: Variable Number Of Rows Of Texboxes
« Reply #15 on: Apr 6th, 2015, 2:23pm »

Quote:
Here is a complete scrolling solution. Enjoy!

Richard.


Richard,

The solution has a continues vertical scroll, can you modified it to be a horizontal continues scroll, that will be grate.

Regards,
Sarmed

User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Re: Variable Number Of Rows Of Texboxes
« Reply #16 on: Apr 6th, 2015, 2:47pm »

Richard,

I just study the code.
Are you put the text boxes on graphic box?
You are the author of LBB is that allowable under LBB?
Carl advice was not to put controls over graphic box that will make (something) unstable.
Richard, would you please extend your example with horizontal scroll bar to be a reference example under LBB.

I remain holding my breath waiting your replay.
Sarmed

User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Variable Number Of Rows Of Texboxes
« Reply #17 on: Apr 7th, 2015, 4:35pm »

on Apr 6th, 2015, 2:23pm, SarmedNafi wrote:
The solution has a continues vertical scroll, can you modified it to be a horizontal continues scroll, that will be grate.

If you mean horizontal instead of vertical then change WS_VSCROLL into WS_HSCROLL, VERTSCROLLBAR into HORIZSCROLLBAR and SB_VERT into SB_HORZ (plus changing the horizontal position in the LOCATE command of course). If you want both, then add the horizontal commands rather than changing the existing code.

Incidentally in the code I published the Tab key doesn't work properly. To fix that add the WS_EX_CONTROLPARENT stylebit to both graphicboxes:

Code:
STYLEBITS #m.gb1, _WS_CLIPCHILDREN + _WS_VSCROLL, 0, _WS_EX_CONTROLPARENT, 0
STYLEBITS #m.gb2, _WS_CLIPCHILDREN, _WS_BORDER, _WS_EX_CONTROLPARENT, 0 

and reverse the order of the SetParent loops:

Code:
for row = TotalRows to 1 step -1
  for col = 9 to 1 step -1
    h$ = "#m.tb";row;col
    hwtb = hwnd(#h$)
    CALLDLL #user32, "SetParent", hwtb as ulong, hwgb2 as ulong, r as long
  next col
next row 

Quote:
Carl advice was not to put controls over graphic box that will make (something) unstable.

I've never noticed any instability from that cause; I think the warning may have applied to an earlier version than 4.04. But anyway it's perfectly safe to put controls in a graphics window in LBB.

Richard.
User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Re: Variable Number Of Rows Of Texboxes
« Reply #18 on: Apr 7th, 2015, 5:57pm »

Thank you Richard,

A wonderful thread you started, a wonderful help you give.
INDEED,
Thanks a lot for the replay.

All the best
Sarmed
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #19 on: Apr 8th, 2015, 11:46am »

Hi Sarmed

Welcome to the group. Tell your friends about LB Booster!

You may find the article at https://lbpe.wikispaces.com/Graphicbox+and+Scrollbars useful.

Ray
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #20 on: Apr 14th, 2015, 5:35pm »

Following on from the code that Richard Russell provided to set up a table using MAPHANDLE, I've progressed quite well, but now I'm trying to get data that has been entered into the table by the user and then print it into a texteditor control. I've tried all sorts of things, but I just can't get my head around it. I've set up the code below, which doesn't work.

Code:
NumOfRows = 4

    for row = 1 to NumOfRows
      for col = 0 to 4
        textbox #w.tb, 10+col*55, row*20, 55, 20
        maphandle #w.tb, "#w.tb";row;col
      next col
    next row
    
texteditor #w.ted, 10, 150, 200,100  
button #w.btn, "CALC", [Calc], UL, 210,150,60,30

open "Textbox grid" for window as #w
'#w.tb42 "Some text"
'wait 

[Calc]
for row = 1 to NumOfRows
   for col = 1 to 4
      h$ = "w.tb";row;col
      b$ = "!contents? h$"
      #w.ted, b$
      maphandle #w.tb, "#w.tb";row;col
   next   
next 

wait
 


What am I doing wrong. How do I get the text entered into the table into the texteditor?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Variable Number Of Rows Of Texboxes
« Reply #21 on: Apr 14th, 2015, 6:16pm »

on Apr 14th, 2015, 5:35pm, RNBW wrote:
How do I get the text entered into the table into the texteditor?

Code:
NumOfRows = 4

    for row = 1 to NumOfRows
      for col = 0 to 4
        textbox #w.tb, 10+col*55, row*20, 55, 20
        maphandle #w.tb, "#w.tb";row;col
      next col
    next row
    
texteditor #w.ted, 10, 150, 200,100  
button #w.btn, "CALC", [Calc], UL, 210,150,60,30

open "Textbox grid" for window as #w
#w.tb42 "Some text"
wait 

[Calc]
#w.ted "!cls"
for row = 1 to NumOfRows
   for col = 1 to 4
      h$ = "#w.tb";row;col
      #h$ "!contents? b$"
      #w.ted, b$
   next   
next 
wait 
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #22 on: Apr 14th, 2015, 6:48pm »

on Apr 14th, 2015, 6:16pm, Richard Russell wrote:
Code:
NumOfRows = 4

    for row = 1 to NumOfRows
      for col = 0 to 4
        textbox #w.tb, 10+col*55, row*20, 55, 20
        maphandle #w.tb, "#w.tb";row;col
      next col
    next row
    
texteditor #w.ted, 10, 150, 200,100  
button #w.btn, "CALC", [Calc], UL, 210,150,60,30

open "Textbox grid" for window as #w
#w.tb42 "Some text"
wait 

[Calc]
#w.ted "!cls"
for row = 1 to NumOfRows
   for col = 1 to 4
      h$ = "#w.tb";row;col
      #h$ "!contents? b$"
      #w.ted, b$
   next   
next 
wait 


It's so obvious isn't it. I thought I'd used all the combinations, but obviously not.
Just a small correction, in the last loop it should be
FOR col = 0 TO 4
otherwise for some reason, it doesn't print the entry from the Row1/Col1 box.

Thanks very much
Ray :)
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #23 on: Apr 15th, 2015, 3:55pm »

I've moved on a bit with my coding and I'm trying out routines to:
a). Only accept numeric input (0-9, -, and .)
b). Format the output to 2 decimal places.

Thanks to a FUNCTION NumberOnly$() written by Bob Bromley on LB Conforums May 5, 2004, I've found code that does that and I've got it to work in my example code. The problem is, it's brought up two problems.

1. When I try to set up loops to clear textboxes, I can't get it to work. As can be seen in the code, I've tried different methods.
2. In the function, if a non-numeric character is entered, a NOTICE pops up. If I put a GOTO a label in the function it just sets up a continuous loop that I can't get out of and if I don't then clearing the NOTICE and removing the offending character then leaves me in limbo. I've tried this with some other code and it works without a GOTO a label, but not in this code.

The code is below:
Code:
' THIS CODE UTILISES A FUNCTION NumberOnly$() written by  Bob Bromley  -  May 5, 2004
' WHICH I HAVE MODIFIED, BECAUSE I ONLY WANT TO ENSURE NUMERIC ENTRY.
' BOB BROMLEY ALSO PRODUCED CODE THAT UTILISES TRIM$ AND USING TO PRODUCE FORMATTED
' NUMERICAL OUTPUT.
' Thank you Bob for the code you produced.

' The code checks numeric entry for each textbox and then produces it, formatted to
' 2 decimal places in the textbox immediately below.  A NOTICE will pop up if a non-
' numeric character is entered and the COMPUTE button pressed.
' The numbers are then listed in a texteditor.
' The COMPUTE button can be pressed after each entry or after all boxes have been
' completed. The downside of the latter, is that the ERROR NOTICE will pop up but 
' won't say which box is incorrect.

NOMAINWIN

' SET UP WINDOW SIZE AND POSITION
WindowWidth = 600 : WindowHeight = 630
UpperLeftX = int((DisplayWidth  - WindowWidth)  / 2)
UpperLeftY = int((DisplayHeight - WindowHeight) / 2)

' SET UP THE CONTROLS
STATICTEXT #m.stat4, "Enter numbers into first four boxes of top row", 35, 0, 400, 20
STATICTEXT #m.stat1, "Unformatted Numbers:  Enter number", 35, 15, 290, 20
STATICTEXT #m.stat3, "TOTAL", 355, 15, 75,20
TEXTBOX    #m.txt11, 35,  40, 75, 20
TEXTBOX    #m.txt12, 110, 40, 75, 20
TEXTBOX    #m.txt13, 185, 40, 75, 20
TEXTBOX    #m.txt14, 260, 40, 75, 20
TEXTBOX    #m.txt15, 335, 40, 75, 20

STATICTEXT #m.stat2, "Formatted Numbers: The numeric results are", 35,  70, 290, 20
TEXTBOX    #m.txt21, 35, 90, 75, 20
TEXTBOX    #m.txt22, 110, 90, 75, 20
TEXTBOX    #m.txt23, 185, 90, 75, 20
TEXTBOX    #m.txt24, 260, 90, 75, 20
TEXTBOX    #m.txt25, 335, 90, 75, 20

STATICTEXT #m.stat5, "Summary Results", 35, 220, 150, 20
TEXTEDITOR #m.Ted1,  35, 250, 300, 150

BUTTON     #m.btn1,  "Reset",   [ResetAll], UL,  60, 160,  60, 25
BUTTON     #m.btn2,  "Compute", [Compute],  UL, 172, 160,  60, 25

'Open a window for showing the controls and entering data
OPEN "Filtered Numeric Input" FOR WINDOW_NF AS #m
#m "trapclose [Quit]"
' I'm not sure of the benefit of the next two lines, because if numbers
' are entered in these boxes they will be overridden by the figures entered
' in the top row, formatted and displayed in the second row and the totals
' calculated and similarly displayed.
'#m.txt15, "!disable"
'#m.txt21, "!disable": #m.txt22, "!disable": #m.txt23, "!disable": #m.txt24, "!disable": #m.txt25, "!disable": 

GOTO [ResetStart]

[Compute]   ' Format the entered numbers and calculate total

'This routine doesn't quite work. It prints out the results
'correctly in the texteditor, but then prints out a series
'of 0.00 before entering the total.
FOR row = 1 TO 2
   FOR col = 1 TO 4
      h1$ = "#m.txt";1;col
      #h1$ "!contents? amt$"
      h2$ = "#m.txt";2;col
      amt = CheckDecPoints(amt$)  ' Check for one decimal point
      amt = NumberOnly(amt$)      ' Make the conversion
      '#h1$, 
      num(row,col) = amt
      
      #h2$, (USING("############.##", num(1,col)))       ' Put the result in the lower textbox
      #m.Ted1, (USING("############.##", num(row,col))) 
      
      maphandle #m.txt, "#m.txt";row;col
   next   
next


total = num(1,1) + num(1,2) + num(1,3) + num(1,4)
amt = total
#m.txt15, amt
#m.txt25, (USING("############.##",amt))
#m.Ted1, (USING("############.##", amt))

WAIT

[ResetAll]  ' Blank the textboxes
FOR row = 1 TO 2
   FOR col = 1 TO 4
      h1$ = "#m.txt";row;col
      h2$ = "#m.txt";row;col
      #h1$, ""
      #h2$, ""
   NEXT col 
NEXT row

#m.Ted1, "!CLS"

[ResetStart]                ' Blank both the textboxes
FOR row = 1 TO 2
   FOR col = 1 TO 4
      h1$ = "#m.txt";row;col
      h2$ = "#m.txt";row;col
      a$ = STR$(0)
      #h1$, "!CLS"
      #h2$, "!CLS"
   NEXT col   
NEXT row

#m.Ted1, "!CLS"

WAIT

[Quit]
CLOSE #m
END

'---------------------------------------------------------------------
'
'              FUNCTIONS
'
'---------------------------------------------------------------------

FUNCTION NumberOnly(in$)         ' Here is the meat of it!
[Start]
FOR i = 1 TO LEN(in$)
    t$ = MID$(in$, i, 1)
    [DoItAgain]
    SELECT CASE
                ' Do nothing if t$ is a numeral or a decimal point
        CASE ASC(t$) = 46 OR (ASC(t$) > 46) AND (ASC(t$) < 58)
                ' A minus sign is ok, as long as it preceeds the numbers
        CASE ASC(t$) = 45 AND i = 1
                
        CASE ELSE
            ' Error!!  Only valid numbers 0-9, - , and . can be entered
            NOTICE "ERROR!!!  Please enter a valid number (0-9  -  . )"
            'GOTO [Start]
            'GOTO [DoItAgain]
    END SELECT
NEXT
NumberOnly = VAL(in$)
END FUNCTION  

    ' We must allow decimal points, but more than 1 will give us an incorrect return.
    ' So the first thing to do is count them, and stop here if there is more than 1.
    ' Use this for severe error-checking.
FUNCTION CheckDecPoints(amt$)
t = 0
FOR i = 1 TO LEN(amt$)
    t$ = MID$(amt$, i, 1) : IF t$ = "." THEN t = t + 1
    IF t > 1 THEN NOTICE "Only 1 decimal point is allowed in the number! " : WAIT
NEXT
END FUNCTION 
'---------------------------------------------------------------------
                                                                                
 


Has anyone got any ideas/solutions?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Variable Number Of Rows Of Texboxes
« Reply #24 on: Apr 15th, 2015, 4:30pm »

on Apr 15th, 2015, 3:55pm, RNBW wrote:
Has anyone got any ideas/solutions?

Delete this line, it's meaningless (there is no handle #m.txt) and breaks the rest of the program by zeroing the textbox handles:

Code:
      maphandle #m.txt, "#m.txt";row;col 

I should perhaps add a test in LBB for an undefined handle being supplied, rather than simply failing 'silently'.

Richard.
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: Variable Number Of Rows Of Texboxes
« Reply #25 on: Apr 15th, 2015, 5:11pm »

on Apr 15th, 2015, 4:30pm, Richard Russell wrote:
Delete this line, it's meaningless (there is no handle #m.txt) and breaks the rest of the program by zeroing the textbox handles:

Code:
      maphandle #m.txt, "#m.txt";row;col 

I should perhaps add a test in LBB for an undefined handle being supplied, rather than simply failing 'silently'.

Richard.


Richard
Thank you for your very prompt resolution of the problem. The code now works nicely, even the NOTICE bit. I've checked back on my other code and found that the maphandle wasn't there, so that is why it worked in that case.

It could be useful to include a check in LBB. It would help to cover up my programming incompetence.

Ray
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls