1

On a Xojo WebApp I created a TextFieldClass with a property "required as boolean".

On a webpage, I have some TextFieldClass objects.

What I want to do is simple… I want to do a self.ControlCount on the webpage, and check if all textFieldClass with the required property with "true" value in fact have contents in it.

Easy, right?…

Dim i as integer
Dim c As textFieldClass
For i=0 To self.ControlCount
    if self.ControlAtIndex(i) isa textFieldClass then
        **c=self.ControlAtIndex(i) // i got an error… expected class textFieldClass, but got class webObject…**
    End If
Next

And if I try:

Dim i as integer
Dim c As WebObject
For i=0 To self.ControlCount
    if self.ControlAtIndex(i) isa textFieldClass then
        c=self.ControlAtIndex(i)
        **if c.required then // I got an error… Type "WebObject" has no member named "required"**
            // do something here…
        end if
    End If
Next

Thanks for your help!

dda
  • 6,030
  • 2
  • 25
  • 34
AleMac
  • 23
  • 5

2 Answers2

2

Try this:

c = TextFieldClass(self.ControlAtIndex(i))
dda
  • 6,030
  • 2
  • 25
  • 34
guest
  • 36
  • 1
1

You were really close. Since controlAtIndex brings back a RectControl you have to cast RectControl to the textFieldClass subclass. Technically the same as above but with more explanation.

Dim i as integer
Dim c As WebObject
For i=0 To self.ControlCount-1 //Fixes mistake in original code.
    if self.ControlAtIndex(i) isa textFieldClass then
        c= textFieldClass(self.ControlAtIndex(i)) //Need to cast here
        if c.required then
            // do something here…
        end if
    End If
Next
BKeeney Software
  • 1,299
  • 6
  • 8