CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 16

Thread: Code error

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    192

    Code error

    Please could anyone look why I receive the errors and advise me to fix them. Many thanks

    Code:
    Public Sub FormatData(ByRef MyForm As System.Windows.Forms.Form, ByRef MyFormValuesOnLoad As Object)
    		
    		On Error GoTo EH
    		Dim MyCOntrol As System.Windows.Forms.Control
    		Dim MyControlCount As Short
    		
    		MyControlCount = 0
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
    
    		For	Each MyCOntrol In MyForm.Controls
    			
    			If TypeOf MyCOntrol Is System.Windows.Forms.TextBox Or TypeOf MyCOntrol Is System.Windows.Forms.CheckBox Or TypeOf MyCOntrol Is System.Windows.Forms.ComboBox Then
    				MyControlCount = MyControlCount + 1
    			End If
    		Next MyCOntrol
    		ReDim MyFormValuesOnLoad(ValueType.MyIndex, MyControlCount)
            MyControlCount = 0
    
            Dim cbo As ComboBox
    
            For Each MyCOntrol In MyForm.Controls
                If TypeOf MyCOntrol Is System.Windows.Forms.TextBox Or TypeOf MyCOntrol Is System.Windows.Forms.CheckBox Or TypeOf MyCOntrol Is System.Windows.Forms.ComboBox Then
                    MyControlCount = MyControlCount + 1
                    MyFormValuesOnLoad(ValueType.MyName, MyControlCount) = MyCOntrol.Name
                    If TypeOf MyCOntrol Is System.Windows.Forms.TextBox Then
                        MyFormValuesOnLoad(ValueType.MyTextOrValue, MyControlCount) = MyCOntrol.Text
                    ElseIf TypeOf MyCOntrol Is System.Windows.Forms.CheckBox Then
                        MyFormValuesOnLoad(ValueType.MyTextOrValue, MyControlCount) = MyCOntrol.Value
                    ElseIf TypeOf MyCOntrol Is System.Windows.Forms.ComboBox Then
                        cbo = CType(MyCOntrol, ComboBox)
                        MyFormValuesOnLoad(ValueType.MyTextOrValue, MyControlCount) = cbo.ListIndex
                    End If
    
                    If isControlArray(MyForm, MyCOntrol) Then
                        MyFormValuesOnLoad(ValueType.MyIndex, MyControlCount) = MyCOntrol.Index
                    Else
                        MyFormValuesOnLoad(ValueType.MyIndex, MyControlCount) = ValueType.NotControlArray
                    End If
                End If
            Next MyCOntrol
    		
    		System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
    		
    		Exit Sub
    EH: 
    		System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
    		MsgBox(Err.Description & " In Form " & MyForm.Name,  , "FormatData")
    	End Sub

    Error messages;

    Error 1 'Value' is not a member of 'System.Windows.Forms.Control'.
    Error 2 'ListIndex' is not a member of 'System.Windows.Forms.ComboBox'.
    Error 3 'Index' is not a member of 'System.Windows.Forms.Control'.
    Last edited by dr223; August 6th, 2010 at 10:20 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured