• (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

Resize Form & Controls For Screen Size - VB6 Rate Topic: ***** 1 Votes

#31 f_htn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-August 09

Posted 20 August 2009 - 12:19 AM

View PostJabber, on 21 Jun, 2008 - 02:05 PM, said:

Google'n help for my game - resize form this looks just like what I need.
So I signed up in hope of help.
I got vb6 and loaded this module and added code to form_load()

I get a err.num 438
"Run-time error '438' Object doesn't support this property or method"
It don't like tab.index

I tried a few changes but nothing helped.

Any clues to why I am getting this error?



View Postf_htn, on 19 Aug, 2009 - 11:16 PM, said:

View PostJabber, on 21 Jun, 2008 - 02:05 PM, said:

Google'n help for my game - resize form this looks just like what I need.
So I signed up in hope of help.
I got vb6 and loaded this module and added code to form_load()

I get a err.num 438
"Run-time error '438' Object doesn't support this property or method"
It don't like tab.index

I tried a few changes but nothing helped.

Any clues to why I am getting this error?


I got the same error when I tried it, did you ever find out why.
Was This Post Helpful? 0
  • +
  • -

#32 l_steiner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-November 09

Posted 10 November 2009 - 07:09 PM

The Zip file seems to be corrupt. Does anyone have the original? :)
LS

View PostLouisda16th, on 6 Oct, 2007 - 04:55 PM, said:

Finally a solution. Thanks a lot PsychoCoder!!! :)
EDIT:
I noticed something however. Suppose you resize your form (manually by click and drag), the SetFontSize() function runs. Now when the screen size reaches a particular lower limit, the font size returned will not be a valid value. So an error is generated. Basically this happens when Font Size becomes zero.

Was This Post Helpful? 0
  • +
  • -

#33 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Posted 11 November 2009 - 03:06 AM

Why use the .zip file? This is a tutorial, so you should learn it, rather a simple copy paste and compile.
Was This Post Helpful? 0
  • +
  • -

#34 l_steiner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-November 09

Posted 11 November 2009 - 08:56 AM

View Postfirebolt, on 11 Nov, 2009 - 02:06 AM, said:

Why use the .zip file? This is a tutorial, so you should learn it, rather a simple copy paste and compile.


I have tried, but could not get the code to work. If I saw it in a project file, I could replicate it. Do you have it working?
Was This Post Helpful? 0
  • +
  • -

#35 l_steiner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-November 09

Posted 12 November 2009 - 07:05 PM

I got it working :D

However I get an error when running when the program tries to resize the form menu. Any ideas how to put this into an If statement?

Thanks in Advance. LS
Was This Post Helpful? 0
  • +
  • -

#36 ravmonster  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 162
  • Joined: 20-July 09

Posted 14 December 2009 - 05:40 AM

Error division by ZERO!!!
@iHeight


Why?????

This post has been edited by ravmonster: 14 December 2009 - 05:46 AM

Was This Post Helpful? 0
  • +
  • -

#37 samipshr@gmail.com  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 26-July 09

Posted 11 January 2010 - 03:41 AM

HI,
anyone have tried this in .NET C#?

If yes please provide the code?

This post has been edited by samipshr@gmail.com: 11 January 2010 - 03:42 AM

Was This Post Helpful? 0
  • +
  • -

#38 vb6king  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-January 10

Posted 27 January 2010 - 05:28 PM

Why is anyone trying to even use this code with .NET?

.NET has good form resizing code, anchors etc since the outset... look at the form and object properties, it is VERY simple and can even anchor to edge of other objects... which is much better than this code.



I've done a little work on this code for myself, I will post it up later/tomorrow.
Was This Post Helpful? 0
  • +
  • -

#39 Guest_josell*


Reputation:

Posted 10 February 2010 - 04:08 AM

i cant run it. there was a problem in priv8 sub form load...
how cud it be?
and anyway,
please help me about assigning two numbers then in a label box there must be a remark that the sum of 2 nos. are > or < 20. :))
thanks!
Was This Post Helpful? 0

#40 Guest_d0uga1*


Reputation:

Posted 02 March 2010 - 12:31 PM

ok i tired this tutorial and run into a few probs i made a user form and put a label and a listbox and a menu

first when resizing i get Run-time error '438' Object doesn't support this property or method then highlights -
Public Sub GetLocation(frm As Form)
Dim i As Integer
'   Load the current positions of each object into a user defined type array.
'   This information will be used to rescale them in the Resize function.
 
'Loop through each control
For Each curr_obj In frm
'Resize the Array by 1, and preserve
'the original objects in the array
        ReDim Preserve List(i)
        With List(i)
                .Name = curr_obj
                .[b]Index = curr_obj.TabIndex[/b]
                .Left = curr_obj.Left
                .Top = curr_obj.Top
                .width = curr_obj.width
                .height = curr_obj.height
        End With
        i = i + 1
 
Next curr_obj
 
'   This is what the object sizes will be compared to on rescaling.
        iHeight = frm.ScaleHeight
        iWidth = frm.ScaleWidth
End Sub


as this only happens when the menubar is present/visible i assume that the tabindex cannot be assigned to this control

how do we bypass this i tried using error handle but cannot seem to grasp error handling as of yet

can we have a solution if possible where the resize works with a menubar.

secondly this is for information only the error regarding the setfontsize() i managed to work this out by adding this statment in both form_load() & form_resize()

 If lblinstructions.FontSize < 8 Then
            lblinstructions.FontSize = SetFontSize
        End If


thanks for any help with the menubar resize.
Was This Post Helpful? 0

#41 Guest_d0uga1*


Reputation:

Posted 02 March 2010 - 03:13 PM

View Postd0uga1, on 02 March 2010 - 11:31 AM, said:

ok i tired this tutorial and run into a few probs i made a user form and put a label and a listbox and a menu

first when resizing i get Run-time error '438' Object doesn't support this property or method then highlights -
Public Sub GetLocation(frm As Form)
Dim i As Integer
'   Load the current positions of each object into a user defined type array.
'   This information will be used to rescale them in the Resize function.
 
'Loop through each control
For Each curr_obj In frm
'Resize the Array by 1, and preserve
'the original objects in the array
        ReDim Preserve List(i)
        With List(i)
                .Name = curr_obj
                .[b]Index = curr_obj.TabIndex[/b]
                .Left = curr_obj.Left
                .Top = curr_obj.Top
                .width = curr_obj.width
                .height = curr_obj.height
        End With
        i = i + 1
 
Next curr_obj
 
'   This is what the object sizes will be compared to on rescaling.
        iHeight = frm.ScaleHeight
        iWidth = frm.ScaleWidth
End Sub


as this only happens when the menubar is present/visible i assume that the tabindex cannot be assigned to this control

how do we bypass this i tried using error handle but cannot seem to grasp error handling as of yet

can we have a solution if possible where the resize works with a menubar.

secondly this is for information only the error regarding the setfontsize() i managed to work this out by adding this statment in both form_load() & form_resize()

 If lblinstructions.FontSize < 8 Then
            lblinstructions.FontSize = SetFontSize
        End If


thanks for any help with the menubar resize.




ok been working with this and got a solution to the probelm with resizing with a menubar added to the userform

here is what i added to the module code
If curr_obj = FileMenuBar Then
        On Error GoTo ErrorH


ErrorH:
    If Err.Number = 438 Then
' do nothing
    Err.Clear
    End If


and it sits in the module like this


Public Sub ResizeControls(frm As Form)
Dim i As Integer
'   Get ratio of initial form size to current form size
x_size = frm.ScaleHeight / iHeight
y_size = frm.ScaleWidth / iWidth
 
'Loop though all the objects on the form
'Based on the upper bound of the # of controls
For i = 0 To UBound(List)
        'Grad each control individually
        For Each curr_obj In frm
        If curr_obj = FileMenuBar Then
            On Error GoTo ErrorH
                            'Check to make sure its the right control
                If curr_obj.TabIndex = List(i).Index Then
                        'Then resize the control
                         With curr_obj
                                .Left = List(i).Left * y_size
                                .width = List(i).width * y_size
                                .height = List(i).height * x_size
                                .Top = List(i).Top * x_size
                         End With
                End If
                End If
ErrorH:
    If Err.Number = 438 Then
    Err.Clear
    End If
        'Get the next control
        Next curr_obj
Next i
End Sub



Public Sub GetLocation(frm As Form)
Dim i As Integer
'   Load the current positions of each object into a user defined type array.
'   This information will be used to rescale them in the Resize function.
 
'Loop through each control
For Each curr_obj In frm
'Resize the Array by 1, and preserve
'the original objects in the array
    If curr_obj = FileMenuBar Then
        On Error GoTo ErrorH
        ReDim Preserve List(i)
        With List(i)
                .Name = curr_obj
                .Index = curr_obj.TabIndex
                .Left = curr_obj.Left
                .Top = curr_obj.Top
                .width = curr_obj.width
                .height = curr_obj.height
        End With
        i = i + 1
ErrorH:
    If Err.Number = 438 Then
' do nothing
    Err.Clear
    End If
    End If
Next curr_obj
 
'   This is what the object sizes will be compared to on rescaling.
        iHeight = frm.ScaleHeight
        iWidth = frm.ScaleWidth
End Sub


Was This Post Helpful? 0

#42 vbcoder1982  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-April 10

Posted 09 April 2010 - 07:04 PM

When I try to download and unzip the file I keep getting "corrupt data" as a message. Any ideas.
Was This Post Helpful? 0
  • +
  • -

#43 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1637
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Posted 15 April 2010 - 08:23 AM

@DocType this code was for Visual Basic 6, not VB.NET (Notice the VB6 in the title). That's probably why it doesn't work
Was This Post Helpful? 0
  • +
  • -

#44 Guest_lsioi*


Reputation:

Posted 07 July 2010 - 06:17 AM

View Postravmonster, on 14 December 2009 - 04:40 AM, said:

Error division by ZERO!!!
@iHeight


Why?????

Was This Post Helpful? 0

#45 Guest_lsioi*


Reputation:

Posted 07 July 2010 - 06:19 AM

View Postravmonster, on 14 December 2009 - 04:40 AM, said:

Error division by ZERO!!!
@iHeight


Why?????

Was This Post Helpful? 0

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4