Visual Basic - AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Life is soft - evento anual de software empresarial
 
Vista:

AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Publicado por anna (45 intervenciones) el 24/06/2006 19:10:22
HOLA, ESTY DESARROLLANDO UN PROGRAMA EN EL CUAL DEBO MEDIR EL LARGO O LA DISTANCIA ENTRE DOS PUNTOS, ES DECIR DIBUJO UNA LINEA Y NECESITO MEDIR Y COLOCAR EN UN LABEL EL LARGO DE ESA LINEA EN CENTIMETROS PARA LUEGO HACER OTROS CALCULOS, SI ALGIEN M PUEDE AYUDAR SE LO AGRADECERIA, GRACIAS DE ANTEMANO
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Publicado por kiko (26 intervenciones) el 24/06/2006 20:27:49
Te paso este código para que te hagas una idea. El resultado que dá no coincide con la distancia de la línea que se ve en el monitor (creo que debe ser por la resolución) pero para hacer cálculos podría valer
.
Dim distancia As Double
Me.ScaleMode = vbCentimeters
distancia = Line1.X2 - Line1.X1
Label1.Caption = Format(distancia, "##0.00")
Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Publicado por ANNA (45 intervenciones) el 24/06/2006 21:19:09
LA CUESTION ES LA SIGUIENTE: TENGO UN PICTURE BOX DONDE ADQUIERO UNA IMAGEN, SOBRE ESA IMAGEN TRAZO UNA LINEA Y ESA ES LA LINEA Q NECESITO MEDIR EN CM Y MOSTRARLO EN UN LABEL O EN UN TEXTBOX, SI M PODRIAS AYUDAR TE LO AGRADECERIA...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Publicado por Javi RM (187 intervenciones) el 26/06/2006 07:53:47
bueno, ten en cuenta que VB mide en Twips. PAra que puedas realizar los cálculos en centimetros debes realizar las conversiones necesarias.

1 twip = 1/20 píxels.
1 centimetro = 567 twips.

Como bien indica kiko, puedes cambiar la unidad de medida a vbcentimeters para trabajar directamente.

Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Publicado por Jamec (231 intervenciones) el 27/06/2006 18:32:36
La formula de distacia entre dos puntos es
Distancia=Sqr((Punto1.x-Punto2.x)^2+(Punto1.y-Punto2.y)^2)
Suerte
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:AYUDA URGENTE DISTANCIA ENTRE DOS PUNTOS!!

Publicado por ANNA (45 intervenciones) el 28/06/2006 19:17:49
EL CODIGO ES EL SIGUIENTE, LO Q HACE ES ADQUIRIR UNA IMAGEN, Y DIBUJAR UNA LINEA SOBRE LA IMAGEN, ESA LINEA ES LA Q NECESITO MEDIR PERO ESTOS CODIGOS NO M FUNCIONAN..... HELP!!

Dim X0 As Single, Y0 As Single
Private Sub Command1_Click()
image1.Stretch = False
End Sub
Private Sub Form_Load()
image1.Picture = Form1.image1.Picture
Form2.Caption = Form1.File1.FileName
OldX = 0
OldY = 0

' Posicion Inicial de las imagenes
Image2.Move 0, 0, ScaleWidth - VScroll1.Width, ScaleHeight - HScroll1.Height
image1.Move 0, 0

' posicion inicial scrollbar horizontal
HScroll1.Top = Image2.Height
HScroll1.Left = 0
HScroll1.Width = Image2.Width

' posicion inicial scrollbar vertical
VScroll1.Top = 0
VScroll1.Left = Image2.Width
VScroll1.Height = Image2.Height

'Determina si la imagen se sobresale de la pantalla,
'sino, deja de hacer visible las scrollbar

VScroll1.Visible = (Image2.Height < image1.Height)
HScroll1.Visible = (Image2.Width < image1.Width)
End Sub
Sub HScroll1_Change()
' Picture2.Left is set to the negative of the value because
' as you scroll the scroll bar to the right, the display
' should move to the Left, showing more of the right
' of the display, and vice-versa when scrolling to the
' left.
image1.Left = -HScroll1.Value
End Sub
Private Sub image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
X0 = X
Y0 = Y
End Sub
Private Sub image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.image1.Line (X0, Y0)-(X, Y), 0
End Sub
Sub VScroll1_Change()
' Picture2.Top is set to the negative of the value because
' as you scroll the scroll bar down, the display
' should move up, showing more of the bottom
' of the display, and vice-versa when scrolling up.
image1.Top = -VScroll1.Value
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
GetCursorPos Pnt
Text1.Text = Pnt.X
Text2.Text = Pnt.Y
NewX = Pnt.X
NewY = Pnt.Y
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar