How to save form size?

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

43 Replies - 3243 Views - Last Post: 24 August 2012 - 06:48 AM Rate Topic: *---- 1 Votes

#31 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 02:37 PM

View Postmodi123_1, on 23 August 2012 - 02:26 PM, said:

A balancing act of pushing for the learning


I learn from codes others have written. I analyze them and after that I knew how to work with it...
Was This Post Helpful? 0
  • +
  • -

#32 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8963
  • View blog
  • Posts: 33,606
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 02:39 PM

A-huh... Again, if you are getting errors - what are they? What is your code doing now that it shouldn't be? Explain! Explain!
Was This Post Helpful? 0
  • +
  • -

#33 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 02:39 PM

View Postmodi123_1, on 23 August 2012 - 02:36 PM, said:

... then what *ARE* the error messages and what not? Again it's all about helping us to better help you!


Uhmmm... I can't give you the errors while I'm sleeping ;-)
Was This Post Helpful? 0
  • +
  • -

#34 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: How to save form size?

Posted 23 August 2012 - 02:41 PM

View PostWhazabazaa, on 23 August 2012 - 02:32 PM, said:

For the people who think I pasted the code so they can do my homework:
I posted my codes to show a bit effort... I could also say what my problem is and say nothing about codes, so you could write the code. I think that's more doing someone's homework! It's posting a fault code (doing something) versus only the problem (doing nothing), I'm just saying...

I admit that not saying the errors was my fault...


It's fine - nobody thinks that. You can usually tell when people just want to steal code, but you're clearly trying to learn it. Also, with regards to your earlier quesiton, no. I'm referring to the rule on not doing people's homework, but not doing yours.



View Postmodi123_1, on 23 August 2012 - 02:26 PM, said:

Quote

I was just making a point that I think it's enforced a little too harsh.

.. and I find instances where it is not enforced enough. Cest la vie. Can't win them all.

Quote

It's kinda like "Don't give them ANY code", but you need to start everyone off with something

(ir)Regardless of my personal pet peeve for the "o n0ez, where doo i startz?!", there is some level of getting the point across. A balancing act of pushing for the learning and just handing out answers. If the written answer is not understood then it's a guessing game of what part of the words the op would have failed on and it becomes time to refactor and explain those words.. and so on and so on...


Oui, mon ami. I agree. Although I'm 14, I've come to learn some of the things on starting new languages, even earlier I was trying to learn Ruby, but I don't think I'll get into it.
Was This Post Helpful? 0
  • +
  • -

#35 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8963
  • View blog
  • Posts: 33,606
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 02:44 PM

If you are sleeping.. then who is responding to us?!

Posted Image
Was This Post Helpful? 1
  • +
  • -

#36 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 02:48 PM

View Postmodi123_1, on 23 August 2012 - 02:44 PM, said:

If you are sleeping.. then who is responding to us?!

Posted Image


OMG, are you serious, sounds a bit childish? I'm trying to sleep, ok?
Was This Post Helpful? 0
  • +
  • -

#37 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8963
  • View blog
  • Posts: 33,606
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 02:49 PM

Bwahahaha.. then put down the pda/smartphone/keyboard/laptop/web enabled clam and get some shut eye! ;)
Was This Post Helpful? 0
  • +
  • -

#38 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 02:53 PM

View Postmodi123_1, on 23 August 2012 - 02:49 PM, said:

Bwahahaha.. then put down the pda/smartphone/keyboard/laptop/web enabled clam and get some shut eye! ;)


Thank you, thanks to you I'll be having a nightmare about the ERRORS :-D

This post has been edited by Whazabazaa: 23 August 2012 - 02:55 PM

Was This Post Helpful? 0
  • +
  • -

#39 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8963
  • View blog
  • Posts: 33,606
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 04:58 PM

Here's part of my nightmares..

Spoiler


Okay.. okay.. I'll wait until we have more information tomorrow.
Was This Post Helpful? 0
  • +
  • -

#40 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 10:27 PM

View Postmodi123_1, on 23 August 2012 - 04:58 PM, said:

Here's part of my nightmares..

Spoiler


Okay.. okay.. I'll wait until we have more information tomorrow.


Haha, epic!

Ontopic:

The code I used a several posts ago doesn't had any error's, warnings or messages (but doesn't work!):

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim A As New SizesForms

        A.HeightFORM = Me.Size.Height
        A.WidthFORM = Me.Size.Width
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim A As New SizesForms()
        Me.Size = New System.Drawing.Point(A.HeightFORM, A.WidthFORM)
    End Sub



Public Class SizesForms
    Public HeightFORM As Double
    Public WidthFORM As Double
End Class


But I had two errors and warnings because I had Dim A As SizesForms instead of Dim A As New SizesForms.

If I have Dim A As SizesForms:

Public Class Form2
    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim A As SizesForms

        A.HeightFORM = Me.Size.Height
        A.WidthFORM = Me.Size.Width
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim A As SizesForms()
        Me.Size = New System.Drawing.Point(A.HeightFORM, A.WidthFORM)
    End Sub
End Class



Public Class SizesForms
    Public HeightFORM As Double
    Public WidthFORM As Double
End Class


With the following errors:
1) 'WidthFORM' is not a member of 'System.Array'.
2) 'HeightFORM' is not a member of 'System.Array'.
3) Variable 'A' is used before it has been assigned a value. A null reference exception could result at runtime.


Whaza
Was This Post Helpful? 0
  • +
  • -

#41 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 10:35 PM

Used the solution from post #24 of ToshNeox and it works. Really easy and with no problems!

Thanks, Tosh
Was This Post Helpful? 0
  • +
  • -

#42 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: How to save form size?

Posted 24 August 2012 - 12:53 AM

View PostWhazabazaa, on 23 August 2012 - 10:35 PM, said:

Used the solution from post #24 of ToshNeox and it works. Really easy and with no problems!

Thanks, Tosh


Glad it's fixed. Sometimes simpler is better.
Was This Post Helpful? 0
  • +
  • -

#43 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 262
  • View blog
  • Posts: 1,461
  • Joined: 07-April 08

Re: How to save form size?

Posted 24 August 2012 - 05:39 AM

View PostWhazabazaa, on 24 August 2012 - 12:27 AM, said:

The code I used a several posts ago doesn't had any error's, warnings or messages (but doesn't work!):

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim A As New SizesForms

        A.HeightFORM = Me.Size.Height
        A.WidthFORM = Me.Size.Width
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim A As New SizesForms()
        Me.Size = New System.Drawing.Point(A.HeightFORM, A.WidthFORM)
    End Sub



Public Class SizesForms
    Public HeightFORM As Double
    Public WidthFORM As Double
End Class



Just so that you can get an understanding as to why this didn't work. (Note: I would highly suggest reading this to help you understand about Scope.)

Basically in the FormClosing event you are creating a new SizesForms as you should be, but you don't store that anywhere that is accessable once the form is closed. So that variable has a scope that is only that method. Once that method ends that variable is trashed so to speak.

Now, in the Form2_Load event you are also creating a new SizesForms object. This is never going to give you the results you expected because the properties within that object are going to be set to the default (in this case 0,0). The scope of this variable is only that of the load event, and nothing more. Just because you named it the same as the variable in the FormClosing event doesn't mean the properties will be set the same. They are within two different Scopes.

A quick lesson on scope:

Scope basically means the section of code that something is "alive" in. Meaning that you can access that variable at any point in the code where you created it.

EX:


Public Class Foo
    Dim Narf as String

    Public Sub New()
        Dim Chu as String
    End Sub

    Public Sub Print()
        Console.WriteLine(Narf)
        Console.WriteLine(Chu)
    End Sub
End Class  




So Because we've declared Narf right after the declaration of the class Foo we say that it is a Class level variable. It is called that because it is accessable by any piece of code within that class. It cannot, however, be accessed by anything outside of that class.

Now The variable Chu was declared in the Sub called New. This variable is called a Local variable because it's scope is only that sub in which it was created. It would not be accessible to any other part of that class or anything outside of that class because once the sub New is finished that variable is "killed" or deallocated. So if we tried to call Console.WriteLine like in the print method and pass it the Chu variable, it would give us a compiler error because the Print Method does not know what Chu is.

This post has been edited by rgfirefly24: 24 August 2012 - 05:46 AM

Was This Post Helpful? 1
  • +
  • -

#44 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 24 August 2012 - 06:48 AM

Thank you! I learned a lot from your post, tanks!
Was This Post Helpful? 0
  • +
  • -

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