Consulta, ya que estoy aprendiendo esto.
Tengo dos rutinas que hacen cosas diferentes sacadas de un ejemplo.
1.- EN la primera declaro un objeto pero no uso la palabra clave NEW.:
Dim myhostentry As System.Net.IPHostEntry
Dim myipaddr As System.Net.IPAddress
2.- En la segunda necesito usar una funcion especifica y al declarar el
objeto de esa funcion uso NEW.
Dim randominteger As New System.Random
En uno de los objetos del primer ejemplo "Dim myipaddr As
System.Net.IPAddress" no se me pertime el uso de New se marca con error
Entiendo como se usa este concepto en Visual 6, pero aqui tengo mis dudas.
Desde ya Gracias
Alberto Guerrero
''PRIMER PROCEDIMIENTO
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Dim myhostname As String = Dns.GetHostName
Dim myhostname As String
Dim myhostentry As System.Net.IPHostEntry
Dim myipaddr As System.Net.IPAddress
myhostname = Dns.GetHostName
''myhostentry = Dns.GetHostByName(myhostname)
For Each myipaddr In myhostentry.AddressList
MessageBox.Show("TU IP ES:=" & myipaddr.ToString)
Next
myhostentry = Nothing
myipaddr = Nothing
End Sub
''SEGUNDO PROCEDIMIENTO
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim temparray() As String
Dim randominteger As New System.Random
Dim curindex As Integer
Dim numelements As Integer = Val(txtarraysize.Text)
If (numelements > 0) Then
ReDim temparray(numelements)
For curindex = 0 To numelements - 1
temparray(curindex) = randominteger.Next
Next
End If
txtoutput.Text = String.Join(", ", temparray)
End Sub
Leer las respuestas