PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: question about Mid(function)  (Read 376 times)

veltesian

  • Little Newbie
  • *
  • Posts: 47
question about Mid(function)
« on: July 25, 2020, 12:42:50 PM »

hello everyone....

i have this idea about needing to using a textbox or something in like a TextChanged event
at runtime. i have a snip of an example below:

Mid((Form1.Tx2.text), 3, 3)  <---- i'd like to figure out how could a text box be used to
affect the start position of the substring & a text box used to affect the substring length
as i mentioned i was trying to figure out how to arrange such code so that it could operate
in runtime mode.
Logged

raymw

  • Senior Member
  • ***
  • Posts: 409
Re: question about Mid(function)
« Reply #1 on: July 25, 2020, 10:28:47 PM »

Do you mean you want a couple of text boxes, one to have a number to indicate the start position, and one to show the length? use valint to get the text to an integer.
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 47
Re: question about Mid(function)
« Reply #2 on: July 26, 2020, 05:09:01 AM »

hello ray ..

thanks a million ray it actually worked with the code i had within the form i just simply had to
Dim 2 strings (the 2 textboxes that i need to have work) using "Valint" as a transformer on the
2 values within the MID(function) for conversion & then binding that to a command button.

right on! :D
« Last Edit: July 26, 2020, 05:17:04 AM by veltesian »
Logged

raymw

  • Senior Member
  • ***
  • Posts: 409
Re: question about Mid(function)
« Reply #3 on: July 26, 2020, 12:05:38 PM »

glad to be of help. Now you need to think about how to handle the situation when folk do not enter a number- use a message box to remind them, say., or a tool tip.
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 47
Re: question about Mid(function)
« Reply #4 on: July 26, 2020, 10:16:18 PM »

hello ray ......

well its official, i'm stumped in trying to make a textbox show only numbers when keys are typed.
i was hoping i could get just a little bit of direction on this if its possible? actually i'd like to code it
in a way that the user can ONLY type numbers with all other characters typed just be ignored.
also i don't want to include a msgbox to alert the user,....just that the only keys that should show
in the textbox are numbers.
« Last Edit: July 26, 2020, 10:24:38 PM by veltesian »
Logged

James Klutho

  • Senior Member
  • ***
  • Posts: 255
  • Petroleum Software Solutions
Re: question about Mid(function)
« Reply #5 on: July 26, 2020, 11:54:02 PM »

You have to sub class the textbox and intercept the key strokes before they reach the textbox and do your processing in the subclass.  Sub classing is more advanced but not difficult once you see how it is done.  There may be examples on this forum but for sure there are tons of examples on the Power Basic forum.
Logged

Johan Klassen

  • Junior Member
  • **
  • Posts: 107
  • FF3 User
Re: question about Mid(function)
« Reply #6 on: July 27, 2020, 12:12:51 AM »

if the input is of fixed format like a phone number or social security number then you could use a masked edit control instead of a text box
Logged

philbar

  • Little Newbie
  • *
  • Posts: 18
Re: question about Mid(function)
« Reply #7 on: July 27, 2020, 03:04:31 AM »

This seems to work: add a line to the Form Load event.

Code: [Select]
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT

   afxaddwindowstyle(frmmain.Text1.hWindow, es_number)

   Function = 0
End Function

Hmm. You said you didn't want a popup. Back in the old days, number-only boxes just dinged when you typed a letter. Oh, well.
« Last Edit: July 27, 2020, 03:15:43 AM by philbar »
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 47
Re: question about Mid(function)
« Reply #8 on: July 27, 2020, 07:24:52 AM »

hello philbar....

i tried to use the below code which was a slight change from your code philbar
but i still appreciate the assistance as well my appreciation in help from johan klassen &
james klutho:

    Function Form1_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
    afxaddwindowstyle(Form1.Text1.hWindow, es_number)
    Function = 0
    End Function

i kept getting a variable not declared error from the compiler. it seems to not like the "frmMain"
as a form loading function. the above code worked nicely. i very much appreciate your help philbar.
« Last Edit: July 27, 2020, 10:12:19 AM by veltesian »
Logged