11 Replies - 294 Views - Last Post: 20 October 2017 - 09:27 AM Rate Topic: -----

#1 ggbuttman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-October 17

HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 07:37 AM

Public Class Form_TheActivity

    Public TheActivityNumber As Integer
    Public StudUser As String

    Private DB As New ClassStudentDB
    Private mDataset As New DataSet
    Private mTable As New DataTable

    Private PageIndex As Integer
    Private NumQuestions As Integer
    Private EndQuestion As Boolean
    Private Confirm

    Private ActivityTime As Integer = 1200
    Private TSpan As TimeSpan



Is there a way i can change the value of
"Private ActivityTime As Integer = 1200" <--- Using other form? pls help ty.

Is This A Good Question/Topic? 0
  • +

Replies To: HELP! how can i change the value of ActivityTime using other form

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 07:39 AM

Make a public property that exposes your private parts.

https://docs.microso...nted-properties
Was This Post Helpful? 0
  • +
  • -

#3 ggbuttman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-October 17

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 07:44 AM

can you pls make an example of that im just new in vb and im not that good in this
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 07:50 AM

Read the link. Any example would just be doing it for you.
Was This Post Helpful? 0
  • +
  • -

#5 ggbuttman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-October 17

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 08:06 AM

i dont really understand it. im not that good in english. can you pls help me on how can i change the value of ActivityTime using other form T_T
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 08:28 AM

Come on, buttman! Please read the link and try.

Also be aware of the rules regarding asking people to do your work for you.
Was This Post Helpful? 0
  • +
  • -

#7 ggbuttman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-October 17

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 08:41 AM

Public Property ActivityTime As Integer



i tried to make it like this and connect it on a button

Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form_TheActivity.ActivityTime = 2000
    End Sub
End Class



but it didnt change.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 08:41 AM

Did you declare an instance of the form and use that or thought you just wanted to put the actual class name of the form in there?
Was This Post Helpful? 0
  • +
  • -

#9 ggbuttman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-October 17

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 08:59 AM

i didnt understand what you said
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 09:02 AM

Okay.. so I am going to assume "Form_TheActivity" is the actual name of your form, right? The class that is you form.
3        Form_TheActivity.ActivityTime = 2000


You need to make a variable of that type, instantiate it (aka 'new'), and THEN you can use the properties.

dim foo as new Form_TheActivity()
foo.ActivityTime = 2000



If you don't then it's like wanting to change a string
dim bar string = "nuts"

.. but instead you are just saying
string = "nuts"

Was This Post Helpful? 0
  • +
  • -

#11 ggbuttman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-October 17

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 09:20 AM

Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim foo As New Form_TheActivity()
        foo.ActivityTime = 2000
    End Sub
End Class



i tried it but the value of ActivityTime is still not changing

ublic Class Form_TheActivity

    Public TheActivityNumber As Integer
    Public StudUser As String

    Private DB As New ClassStudentDB
    Private mDataset As New DataSet
    Private mTable As New DataTable

    Private PageIndex As Integer
    Private NumQuestions As Integer
    Private EndQuestion As Boolean
    Private Confirm

    Public Property ActivityTime As Integer = 1200
    Private TSpan As TimeSpan


Was This Post Helpful? 0
  • +
  • -

#12 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: HELP! how can i change the value of ActivityTime using other form

Posted 20 October 2017 - 09:27 AM

Go back and read up over how scope works.. and think hard about what happens when you create an object. It exists inside the start and end it was created. If you declare a variable inside an event it only exists while that event method is happening. If you want it to last longer then perhaps declare it global.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1