Solved

Not a member of System.Windows.Forms.Form ?

Posted on 2010-08-31
3
1,349 Views
Last Modified: 2013-11-26
Hello All:
Please let me know what I am doing wrong.  I'm trying to work my add comment form to work for all forms where a comment is required.  So, when I call it from the different forms I set the tag property to the form's name and use it  to initialize my shared form variable and call the function to fill the richtextbox in the calling form which it needs to use the same name in the calling form.  The part that is not working is: frm.txtComments.text  It says that txtComments is not a member of System.Windows.Forms.Form.  This is the code:
Public Class frmAddComment
    Shared frm As Form
    Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
        Call AddCommentToTextBox(frm)
        Me.Close()

    End Sub


    Private Sub AddCommentToTextBox(ByVal frm As Form)
        frm.txtComments.text = frm.txtComments.text & vbCrLf & Now() & ".." & Me.txtNewComment.Text
    End Sub

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        Me.txtNewComment.Text = ""
        Me.Close()

    End Sub

    Public Sub New()
        InitializeComponent()
        If Me.Tag = "frmDetail" Then
            frm = frmDetail
        ElseIf Me.Tag = "frmNewProspect" Then
            frm = frmNewProspect
        End If
    End Sub
End Class

Open in new window

0
Comment
Question by:gloriagalvez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33571472
Try this:

    Private Sub AddCommentToTextBox(ByVal frm As Form)
        If frm.Tag = "frmDetail" Then
            frm = frmDetail
        ElseIf frm.Tag = "frmNewProspect" Then
            frm = frmNewProspect
        End If
        frm.txtComments.text = frm.txtComments.text & vbCrLf & Now() & ".." & Me.txtNewComment.Text
    End Sub

Open in new window

0
 
LVL 17

Accepted Solution

by:
Zhaolai earned 500 total points
ID: 33571539
Ooops, the first post does not work either. Try this:

    Private Sub AddCommentToTextBox(ByVal frm As Form)
        If frm.Tag = "frmDetail" Then
            frmDetail.txtComments.text = frmDetail.txtComments.text & vbCrLf & Now() & ".." & Me.txtNewComment.Text
        ElseIf frm.Tag = "frmNewProspect" Then
            frmNewProspect.txtComments.text = frmNewProspect.txtComments.text & vbCrLf & Now() & ".." & Me.txtNewComment.Text
        End If
    End Sub

Open in new window

0
 

Author Closing Comment

by:gloriagalvez
ID: 33571614
Thank you so much.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C#.net split string and then check appropriate checkboxlist 4 44
add criteria to query in VB, Access 2003 2 31
Nested forach loop to linq 3 28
Adjust the codes 3 31
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question