Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for a snazzy way
Message
 
 
À
25/07/2001 05:29:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00534851
Message ID:
00535007
Vues:
15
>Hi All,
>
>I'm looking for a neat way to do the following case statement.. it's to set a input mask depending on decimal places
>
>
>Do Case
>Case Thisform.decPlaces = 0
>	lcIm = '99999999'
>Case Thisform.decPlaces = 1
>	lcIm = '999999.9'
>Case Thisform.decPlaces = 2
>	lcIm = '99999.99'
>Otherwise
>	lcIm = '99999999'
>EndCase
>
>
>The closest I have got is this
>
>lcIm = '99999999'
>lcIm = Stuff(lcIm, Len(lcIm)-Thisform.decPlaces, 1, '.')
>
>But this falls down on 0 dp
>
>Anyone got any ideas?
>
>TIA
Would this help?
********************************************************************
*  Description.......: SetReplaceValAttr
*  Calling Samples...: thisform.SetReplaceValAttr(alltrim(this.value))
*  Parameter List....: lcField
*  Created by........: Nadya Nosonovsky 06/23/2000 03:46:22 PM
*  Modified by.......: Nadya Nosonovsky 06/27/2000 05:05:42 PM
********************************************************************
lparameters tcField
local lcType, lnSize, lnElement, lnFound, lnDigits
with thisform
	lnFound=ascan(.abldmflds, m.tcField) && Search for this field
	lnElement=asubscript(.abldmflds, m.lnFound,1)
	.cFieldType=.abldmflds[m.lnElement, 2] && The type of the field
	lcType = .cFieldType
	lnSize= .abldmflds[m.lnElement, 3] && Field size
	lnDigits= .abldmflds[m.lnElement, 4] && Decimal places

	if .globOPt.value=1 && Replace with constant
		with .ReplaceVal
			.format=''
			.inputmask=''

			do case
			case m.lcType = "C"
				.value = ""
				.format='R'
				.inputmask=replicate('X', m.lnSize)

			case m.lcType $ "NFIY"
				.value = 0
				if m.lcType='Y' && currency
					.format='$'
				endif
				if m.lcType='N'
					if m.lnDigits>0
						.inputmask=replicate('9',m.lnSize-m.lnDigits-1)+'.'+replicate('9',m.lnDigits)
					else
						.inputmask=replicate('9',m.lnSize)
					endif
				endif

			case m.lcType = "D" && Date
				.value = {}
				.format='YL'

			case m.lcType = "T" && Datetime
				.value = ctot('')
				.format='YL'

			case m.lcType = "L"
				.value = .f.

			case m.lcType='M' && Memo
				.value = ""
			endcase
		endwith
	endif
endwith
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform