ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validate part of string (https://www.excelbanter.com/excel-programming/398905-validate-part-string.html)

Karen53

Validate part of string
 
Hi,

I'm not sure how to go about this. I need to validate a textbox. Any value
can be in the textbox but if certain values are there they need to be the
first item in the box and 3 of them must be spelled correctly. The items:
"Major", "Major Tenant", & "Anchor" must be spelled correctly, but they can
have additional information after them.

Here's what I have so far:

i = InStr(frmStoreData.txtAddUnitNos, "Maj")
If i < 1 Then
MsgBox ("Major must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Anc")
If i < 1 Then
MsgBox ("Anchor must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Pad")
If i < 1 Then
MsgBox ("Pad must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Ret")
If i < 1 Then
MsgBox ("Retail must be the first item listed")
Good = False
End If

How would I check the spelling for just that portion of the string?
--
Thanks for your help.
Karen53

Tim Williams

Validate part of string
 
It might be easier to place a listbox containing the items "Major","Major
Tenant", etc before the textbox, and allow the user to select from that list
if appropriate before typing any additional text in the textbox. Then just
concatenate the selected list item with the textbox contents.

Tim

"Karen53" wrote in message
...
Hi,

I'm not sure how to go about this. I need to validate a textbox. Any
value
can be in the textbox but if certain values are there they need to be the
first item in the box and 3 of them must be spelled correctly. The items:
"Major", "Major Tenant", & "Anchor" must be spelled correctly, but they
can
have additional information after them.

Here's what I have so far:

i = InStr(frmStoreData.txtAddUnitNos, "Maj")
If i < 1 Then
MsgBox ("Major must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Anc")
If i < 1 Then
MsgBox ("Anchor must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Pad")
If i < 1 Then
MsgBox ("Pad must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Ret")
If i < 1 Then
MsgBox ("Retail must be the first item listed")
Good = False
End If

How would I check the spelling for just that portion of the string?
--
Thanks for your help.
Karen53




Karen53

Validate part of string
 
Thank you, Tim.
--
Thanks for your help.
Karen53


"Tim Williams" wrote:

It might be easier to place a listbox containing the items "Major","Major
Tenant", etc before the textbox, and allow the user to select from that list
if appropriate before typing any additional text in the textbox. Then just
concatenate the selected list item with the textbox contents.

Tim

"Karen53" wrote in message
...
Hi,

I'm not sure how to go about this. I need to validate a textbox. Any
value
can be in the textbox but if certain values are there they need to be the
first item in the box and 3 of them must be spelled correctly. The items:
"Major", "Major Tenant", & "Anchor" must be spelled correctly, but they
can
have additional information after them.

Here's what I have so far:

i = InStr(frmStoreData.txtAddUnitNos, "Maj")
If i < 1 Then
MsgBox ("Major must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Anc")
If i < 1 Then
MsgBox ("Anchor must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Pad")
If i < 1 Then
MsgBox ("Pad must be the first item listed")
Good = False
End If

i = InStr(frmStoreData.txtAddUnitNos, "Ret")
If i < 1 Then
MsgBox ("Retail must be the first item listed")
Good = False
End If

How would I check the spelling for just that portion of the string?
--
Thanks for your help.
Karen53






All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com