forms coding to module (Urgent)

I

Ian B

I have a form coding that changes a varible to double spacing by use of space.

What I need to know is how do I change it to a module with the following
answered:-

a) How to I call the module from the form coding passing text0 to module

b) How do I get the answer from module to text2 in the forms coding.

it is as follows

Private Sub Command4_Click()


Dim SngString As String
Dim DblString As String
Dim nos As Double


SngString = Text0 'text0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"



nos = Len(SngString)


For nos = 1 To nos
DblString = DblString & Mid(SngString, nos, 1) & " "
Next nos

Text2 = DblString 'dblstring should be now = "A B C D E F G H I J K L
M N O P Q R S T U V W X Y Z"


End Sub
 
C

Chris L via AccessMonster.com

You need to create a public function in a module:-

Public Function DoubleSpace(ByVal SngString as string) as String
Dim DblString As String
Dim nos As Double

nos = Len(SngString)
For nos = 1 To nos
DblString = DblString & Mid(SngString, nos, 1) & " "
Next nos

DoubleSpace= DblString
End Function


You can now use this function in form code like this:-

Me!Text2 = DoubleSpace(Me!Text0)


hth

Chris
 
I

Ian B

Thanks very much - Just the Ticket

Chris L via AccessMonster.com said:
You need to create a public function in a module:-

Public Function DoubleSpace(ByVal SngString as string) as String
Dim DblString As String
Dim nos As Double

nos = Len(SngString)
For nos = 1 To nos
DblString = DblString & Mid(SngString, nos, 1) & " "
Next nos

DoubleSpace= DblString
End Function


You can now use this function in form code like this:-

Me!Text2 = DoubleSpace(Me!Text0)


hth

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top