2 Questions from a student

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 27
Reputation: gouki2005 is an unknown quantity at this point 
Solved Threads: 0
gouki2005 gouki2005 is offline Offline
Light Poster

2 Questions from a student

 
0
  #1
Aug 26th, 2008
look this ...why is not the same?

  1. Dim azar As New Random
  2. setd1(azar.Next(1, 7))
  3. setd2=(azar.Next(1, 7))

the second one setd2 give me a error... is not the same using =??
Which is the difference???
and...

  1. Dim dados As New dado
  2. dim dados2 as dado

Is this the same...o are Different? and again
Which is the difference??
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: 2 Questions from a student

 
0
  #2
Aug 26th, 2008
Hi

What is "setd1" and "setd2"?
i am not sure what is happening, but it looks to me that they are procedures that dont return anything, maybe?

about the second one,
  1. Dim dados As New dado
  2. dim dados2 as dado

the first one you are creating a new object/variable (hence the word new) of type dado; the second one you are declaring a variable that probably has not been initialized yet.

hope it helps.

- Tutankamon
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 27
Reputation: gouki2005 is an unknown quantity at this point 
Solved Threads: 0
gouki2005 gouki2005 is offline Offline
Light Poster

Re: 2 Questions from a student

 
0
  #3
Aug 26th, 2008
yeah both are sub....


besides I have one more question........

I am new..in this modules.class...type..is really hard to me when I need to know when use a sub or when I need use a function..like this

I need to know..juan,maria,and pedro age...and I want to know if are equal ...

this easy but I am confuse...if I need use a if...in a sub or in a function..

I have this

  1. Public Class calcular
  2. Private juan, maria, pedro As Byte
  3.  
  4. Public Sub setjuan(ByVal value As Integer)
  5. juan = value
  6. End Sub
  7. Public Sub setmaria(ByVal value As Integer)
  8. maria = value
  9.  
  10. End Sub
  11. Public Sub setpedro(ByVal value As Integer)
  12. pedro = value
  13.  
  14. End Sub
  15.  
  16. Public Function getjuan()
  17. Return juan
  18. End Function
  19.  
  20. Public Function getmaria()
  21. Return maria
  22. End Function
  23.  
  24. Public Function getpedro()
  25. Return pedro
  26.  
  27. End Function
  28.  
  29.  
  30. End Class
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: 2 Questions from a student

 
0
  #4
Aug 26th, 2008
ah, although this would work, you are doing it the wrong way.

Usually to set and get the proprties of a class you use the set and get

  1. Public Property X() As Integer
  2. Get
  3. Return x
  4. End Get
  5. Set(ByVal Value As Integer)
  6. x = value
  7. End Set
  8. End Property

what you might want to do is to create a class "person" and with some properties like age, weight, height, etc. Then create an object for each person.

something like this:
  1. public class person
  2. private age, weight, height as integer
  3. ' set your properties here.
  4. end class
  5.  
  6. sub main()
  7. dim juan, maria pedor as person
  8. juan.age = 21
  9. maria.age = 30
  10. pedro.age = 40
  11.  
  12.  
  13. dim ageDiff as integer = maria.age - pedro.age
  14. end sub

something like this.
Last edited by williamrojas78; Aug 26th, 2008 at 4:22 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 339 | Replies: 3
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC