By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,569 Members | 1,630 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,569 IT Pros & Developers. It's quick & easy.

how to declare form textbox in vb module

P: 2
I have a module with an array, so I want the results of an array to be displayed in a form textbox.

When I'm trying to use the texbox in a module a get an error that reads "Error'textbox' is not declared. It may be inaccessible due to its protection level.", so how do I solve this problem?
Feb 7 '13 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,382
We would need to see the code.
Feb 7 '13 #2

P: 2
here are my codes

Expand|Select|Wrap|Line Numbers
  1. Module Module1
  2.     Sub AddCourse(ByVal Team As String, ByRef ReturnString As String)
  3.         Dim Subjects() = {"Ms Office 2007", "internet and commmunications", "Lifetime skills"}
  4.  
  5.         Dim CourseName As String = ""
  6.         Dim Result As String
  7.         Dim i As Short
  8.         Dim Title As String
  9.  
  10.  
  11.  
  12.  
  13.         Dim Prompt, Mn, WrapCharacter As String
  14.         Prompt = "Enter registred Course." & Team
  15.         Mn = InputBox(Prompt, "input box")
  16.         WrapCharacter = Chr(13) + Chr(10)
  17.         ReturnString = Mn & WrapCharacter
  18.  
  19.  
  20.         If Mn = "computer literacy" Then
  21.             Result = "Student is registered for Course name " & CourseName & vbCrLf & vbCrLf
  22.             For i = 0 To UBound(Subjects) ' FOR LOOP TO WRITE AN ARRAY
  23.                 Title = "Subject = " & (i + 1)
  24.  
  25.                 Result = Result & "Subject = " & (i + 1) & vbTab & _
  26.                             Subjects(i) & vbCrLf
  27.  
  28.  
  29.             Next
  30.  
  31.         Else
  32.             MsgBox("Enter computer literacy")
  33.  
  34.         End If
  35.     End Sub
Feb 7 '13 #3

Rabbit
Expert Mod 10K+
P: 12,382
And which line causes the error?
Feb 7 '13 #4

IronRazer
P: 83
Hey tshukela,
I do not see any call to send anything to a textbox but, if i am understanding correct you want to send the (Result) string to a textbox on your form from within the module. If so you could try this :

1. Replace (Form1) with the name of your form that has the textbox on it.
2. Replace (Textbox1) with the name of your textbox.
3. Make sure your textbox (Multiline) property is set to True.

Expand|Select|Wrap|Line Numbers
  1.         For i = 0 To UBound(subjects) ' FOR LOOP TO WRITE AN ARRAY
  2.             result = result & "Subject = " & (i + 1) & vbTab & subjects(i) & vbCrLf
  3.         Next
  4.         Form1.TextBox1.Text = result
  5.  
Feb 9 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.