VB6 runtime error of MSFlexgrid - vb6

Whenever i run my project, it highlights the "Private Sub HighlightGridRow(grd As MSFlexGrid, iRow As Long)" row and pops up a box with the error message "User-defined type not defined". What can i do to make it work?
Private Sub HighlightGridRow(grd As MSFlexGrid, iRow As Long)
With grd
If .Rows > 1 Then
.Row = iRow
.Col = 1
.ColSel = .Cols - 1
.RowSel = iRow
End If
End With
End Sub

VB6 is not knowing what the type MSFlexGrid is, so it's assuming that it's a user-defined type that you haven't defined. More likely, you're trying to use a component that isn't referenced. You need to go to Components in the Project menu and add the Flex Grid component that you're trying to use.
This isn't quite an exact duplicate of this question since it's a different component missing, but you may be able to find more useful information there as well.

Seems likely that MSFlexGrid is not a defined type, probably because you didn't add the OCX to the ToolBox. Maybe the program uses MSHFlexGrid instead and you have copy/pasted code that doesn't fit?
Shouldn't have anything to do with the OCX not being registered. That would more likely fail on an object creation exception instead.

As Peter Cooper Jr said, you probably don't have MSFlexGrid referenced in your project. To do that, go to Project -> Components, then check the box next to "Microsoft FlexGrid Control 6.0" if it's on the list. If not, you will have to click browse and manually add it.
If you can't find the ocx, just download it:
https://www.opendll.com/index.php?file-download=msflxgrd.ocx&arch=32Bit&version=6.0.84.18

Related

How to get content from field

I'm totally new to Base. I have different forms but in one named F_STRUCT of them I'm trying to make a macro which will allow the user to autofill another field when he select a zipcode.
so the database looks like this.
ID_ZIP ZIP CITY
1 97425 Les Avirons
2 82289 Toto
In my forms, I have a select which allows to select the ZIP code. It's label and name is ZipCode.
So I don't really know where to find the API reference for all the methods and chill methods, I followed examples from internet.
I tried this
Sub getZip
Dim Doc As Object
Dim DrawPage As Object
Dim Form As Object
Doc = StarDesktop.CurrentComponent
DrawPage = Doc.DrawPage
Form = DrawPage.Forms.GetByIndex(0)
Toto = Form.GetByName("ZipCode")
Print "hey"
End Sub
But it returns an error on the Toto = Form.GetByName("ZipCode") line.
The code works, so the problem must be how you created the form or control. Follow these instructions to set up a correct example:
Create Form in Design View
Use the List Box tool (is that what you mean by "select"?) and create a control.
Cancel out of the wizard if it pops up.
Right-click on the control and select Control Properties (not Name, which would modify the shape name instead of the control's name).
Set the Name to "ZipCode" (without quotes).
Save and close the form.
Open the form. In the window of that form (the CurrentComponent) go to Tools -> Macros -> Run Macro.
A list of documentation links for Base is at https://ask.libreoffice.org/en/question/80972/to-learn-libreoffice-base-are-there-introductions-or-tutorials/?answer=80973#post-id-80973.

VB6 Custom OCX integrating with another OCX Event/Method

I have created OCX in Vb6 which contains only Listview control(added from MSCOMCTL.ocx) and coded "drag and drop" functionality and currently I want to implement the OCX in another application but I'm not sure how to handle the event.
Listview has predefined Event/Method/Property, when I create my OCX the predified Lisview events are not loaded. example Listview1.Listitem
public sub Listviewocx()
eventvar1 = Data.Files.Count
For intCOunter = 1 To eventvar1
strpath = Data.Files(intCOunter)
msgbox strpath
next
end with
End sub
Thanks
Thiru
When you create ActiveX controls, you don't automatically expose the events, methods and properties of the constituent controls (in your case, the "constituent control" is the ListView). If, for example, you want a user of your control to have access to your ListView's click event, you have to raise the event again in the click event handler. Like this:
Sub ListView1_Click()
RaiseEvent "MyListViewClick"
End Sub
Then, in your application that uses your control:
Sub Listviewocx_MyListViewClick()
'Handle the event here
End Sub
You have to do similar things with properties and methods of your constituent controls.
For more information, read this and the related doc about ActiveX controls.

Visual Basic: Can not access TextBox attribiutes

Sorry. i am officially new in Visual Basic.
I have created a TextBox in my form. In "View Code" i want to access the Text attribute
(I mean TextBox.Text)
,but the object only gives me these 4: Count,Item,LBound,UBound
Maybe you're changing the Index property instead of the TabIndex property so that it would become a control array thus UBound, LBound, Count and Item properties are present.
And i suspect you are using Visual Basic 6 instead of VB.Net.
See link here the VB6 has Index property that is for Control Array.
My guess, without seeing your code is that your syntax is somehow interacting with an array, try this code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TextBox1.Text = "Hello World"
End Sub
End Class
Note: The above code represents the default names for a Form, a new TextBox dragged and dropped onto the designer inside of the form's Load event handler.
Are you possibly copying and pasting a textbox rather than double clicking the object in the toolbox. If you look in the name of the object in the properties window you would see txtName(0)

how to search for all controls on the form in dev express (including sub reports)

I have a dev express report. I want to search for all controls on the report.
The normal convension in windows forms would be:
foreach (Control c in Control.ControlCollection)
{
........
}
Unfortunately this will not work in Dev Express form. Any solutions?
Thanks
There are lots of such questions regarding to find control in report or highlighting cell on mouse over etc..
xrLabel1.Text = ((XRLabel)((XtraReport)xrSubreport1.ReportSource).FindControl("xrLabel1", false)).Text;
subreport control - Check attached sample here
How can set the text of a label on a Subreport?
Check this code snippet to take some idea for your functionality..
Private Sub XtraReport1_BeforePrint(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintEventArgs)
Dim collection As XRControlCollection = (CType(CType(sender, DevExpress.XtraReports.UI.XtraReport),
Q274540.XtraReport1)).Detail.Controls
For i As Integer = 0 To collection.Count - 1
If TypeOf collection(i) Is XRLabel Then
If (CType(collection(i), XRLabel)).DataBindings.Count <> 0 Then
'your code here
End If
End If
Next i
End Sub
XRControl.BeforePrint Event
Report have some structure and you have find control at particular container as you do you in GridView. e.g. find control in editTemplate .. the particular container of the control
Check these links get more information about this:
Loop thru controls of Report or find all visible strings
Find TableCell Controls inside a report
Find all databound controls on report

Access controls of parent dialog in VB6

I have a dialog in vb6 which changes the values being displayed in its parent dialog.
The x1 is displayed in txt_c1 text in parent dialog and it has a txt_1validate function too for the text box. Now i want to change the value of txt_c1 txtbox from child dialog and then call its validate function. But the problem is that txt_c1 is not available in child dialog.
Please note that i am working in vb6 in the MS VB 6.0 IDE
Forms are just classes and can therefore be instantiated explictly (and you will probably find your life easier if you do rather than using the automatic instantiation in VB6) and references to forms can be assigned.
You can solve your problem by creating a public property on your child dialog (Form1.frm) of type Form that you set to the instance of the parent dialog thus giving you access to the controls andd methods on the parent from the child.
My VB6 is somewhat rusty (and I don't have an installed instance available) so this isn't going to be actual, correct code - but something along the lines of the following should work
In the code that calls the child:
Form childDialog = new Form1
childDialog.Parent = this
childDialog.ShowModal
Then in the child dialog:
Parent.txt_c1 = newValue
if not Parent.Validate then
...
end if

Resources