Jump to content

Recommended Posts

Posted

Um bem aja a todos

Tenho uma pequena aplicação executada em VB6 que pretendo refazer a partir do zero em VB2010.

Ao refazer uma rotina aplicando o mesmo principio do VB6 alguns dos valores não são iguais

Os valores reportam ao Valor do angulo e da Corda para um Raio=1 para a divisão dum circulo

Agradecia uma ajuda

Código VB2010

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
 Label11.Text = Round(360 / ComboBox2.Text, 6)  Label13.Text = Mid(360 / ComboBox2.Text, 4, 2)
 'Insere nas Labels os valores correspondentes de angulo, minutos e cordas
 Select Case ComboBox2.SelectedIndex
  'Valores DIVISÃO (valores inteiros)
  '    3  4  5  6  8  9 10  12 15  18  20  24  30  36  40  45  60  72  90
  Case 0, 1, 2, 3, 5, 6, 7, 9, 12, 15, 17, 21, 27, 33, 37, 42, 57, 69, 87
   ' Label11.Text = 360 / ComboBox2.Text
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"
   'Valores DIVISÃO
   '   7  11 13  14  17  19  21  22  23  26  27  28  29  31  32  33  34  35
  Case 4, 8, 10, 11, 14, 16, 18, 19, 20, 23, 24, 25, 26, 28, 29, 30, 31, 32
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid(Mid(360 / ComboBox2.Text, 4, 2) * 60, 1, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"    'Valores DIVISÃO
   '   16  25 
  Case 13, 22
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid(Mid(360 / ComboBox2.Text, 4, 1) * 60, 1, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"
   'Valores DIVISÃO
   '   48  50  75  80  100
  Case 45, 47, 72, 77, 97
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid(Mid(360 / ComboBox2.Text, 1, 1) * 60, 1, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"    'Valores DIVISÃO
   '   37  38  39  41  42  43  44  46  47  49  52
  Case 34, 35, 36, 38, 39, 40, 41, 43, 44, 46, 49, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 66,
   70, 71, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 95, 96
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid(Mid(360 / ComboBox2.Text, 4, 1) * 60, 1, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"
  Case 48, 68, 85, 86
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid((Mid(360 / ComboBox2.Text, 4, 1) * 60 / 10000), 3, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"   Case 18
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 3)
   Label13.Text = Mid((Mid(360 / ComboBox2.Text, 4, 1) * 60 / 10000), 3, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"
  Case 55, 56, 58, 59, 67, 84
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid((Mid(360 / ComboBox2.Text, 3, 2) * 60 / 10000), 3, 2)
   Label14.Text = Round(Sin(Label11.Text * 3.1416 / 360), 4) * 2 & " mm"

 End Select

Código VB6


Private Sub Combo3_Click()

Text15 = Round(360 / Combo3.Text, 2)

Select Case Combo3.ListIndex

   Case 0, 1, 2, 3, 5, 6, 7, 9, 12, 15, 17, 21, 27, 33, 37, 42, 57, 69, 87

       Text10.Visible = False
       Text9.Text = 360 / Combo3.Text
       Text14 = Round(Sin(Text9 * 3.1416 / 360), 4) * 2 & " mm"
       Text14.Visible = True

   Case 4, 8, 10, 11, 14, 16, 19, 20, 23, 24, 25, 26, 28, 29, 30, 31, 32


       Text9.Text = Mid(360 / Combo3.Text, 1, 3)
       Text10.Visible = True
       Text10.Text = Mid(Mid(360 / Combo3.Text, 4, 2) * 60, 1, 2)
       Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"

       Text14.Visible = True

   Case 13, 22

   Text9.Text = Mid(360 / Combo3.Text, 1, 3)
   Text10.Visible = True
   Text10.Text = Mid(Mid(360 / Combo3.Text, 4, 1) * 60, 1, 2)
   Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"
   'Text14 = Round(0.017335 * Combo3.Text, 4) & " mm"
   Text14.Visible = True

   Case 45, 47, 77, 97

   Text9.Text = Mid(360 / Combo3.Text, 1, 2)
   Text10.Visible = True
   Text10.Text = Mid(Mid(360 / Combo3.Text, 3, 1) * 60, 1, 2)
   Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"
   Text14.Visible = True

   Case 34, 35, 36, 38, 39, 40, 41, 43, 44, 46, 49, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 66, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 95, 96

   Text9.Text = Mid(360 / Combo3.Text, 1, 2)
   Text10.Visible = True
   Text10.Text = Mid(Mid(360 / Combo3.Text, 3, 2) * 60, 1, 2)
   Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"
   Text14.Visible = True

   Case 48, 68, 85, 86

   Text9.Text = Mid(360 / Combo3.Text, 1, 2)
   Text10.Visible = True
   Text10.Text = Mid((Mid(360 / Combo3.Text, 4, 1) * 60 / 10000), 3, 2)
   Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"
   Text14.Visible = True

   Case 18

   Text9.Text = Mid(360 / Combo3.Text, 1, 3)
   Text10.Visible = True
   Text10.Text = Mid((Mid(360 / Combo3.Text, 4, 2) * 60 / 10000), 3, 2)
   Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"
   Text14.Visible = True


   Case 55, 56, 58, 59, 67, 84

   Text9.Text = Mid(360 / Combo3.Text, 1, 2)
   Text10.Visible = True
   Text10.Text = Mid((Mid(360 / Combo3.Text, 3, 2) * 60 / 10000), 3, 2)
   Text14 = Round(Sin(Text15 * 3.1416 / 360), 4) * 2 & " mm"
   Text14.Visible = True

   End Select


Posted (edited)

Olá, não percebi bem os resultados que queres apresentar.. nem quais os 97 valores que estão na combo, mas isso parece tudo igual que deve dar para fazer logo tudo de uma vez sem usar o select case...

mas tens ai umas diferenças no nos "mids"

vb.net:

Case 34, 35, 36, 38, 39, 40, 41, 43, 44, 46, 49, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 66,
   70, 71, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 95, 96
   Label11.Text = Mid(360 / ComboBox2.Text, 1, 2)
   Label13.Text = Mid(Mid(360 / ComboBox2.Text, 4, 1) * 60, 1, 2)

o mid tá a pegar a partir do 4

vb6:

Case 34, 35, 36, 38, 39, 40, 41, 43, 44, 46, 49, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 66, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 88, 89, 90, 91, 92, 93, 94, 95, 96

    Text9.Text = Mid(360 / Combo3.Text, 1, 2)
    Text10.Visible = True
    Text10.Text = Mid(Mid(360 / Combo3.Text, 3, 2) * 60, 1, 2)

aqui é a partir do 3, e ha mais umas diferenças...

Edited by vikcch
Posted

Um bem aja a todos

Obrigado desde ja vikcch

A intenção é apresentar os valores dos Graus e Minutos assim como o valor da Corda para a divisão de um circulo até 99 partes iguais.

Só que nas divisões em que o valor do grau não é um valor inteiro ( por isso é que faço o select case) os valores apresentados no VB2010 em comparação com os valores apresentados no VB6 têm alguma diferença, e eu não percebo porquê.

Vou verificar a situação que referes a partir da 3 linha em que aparece " Mid(Mid(360 / Combo3.Text, 3, 2) * 60, 1, 2)"

Posted (edited)

não deve ser isto que queres!!

angulo_e_corda.jpg

mas fica aqui na mesma (vb.net):


Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim raio As Single = InputBox("Valor do Raio?", , "1")
Dim lados As Single = InputBox("Quantas divisoes ou lados?", , "3")
Dim corda As Single = Math.Round(Math.Sin(Math.PI / lados) * 2 * raio, 2)
Dim cadaAnguloInterno As Single = Math.Round(((lados - 2) * 180) / lados, 2)

MsgBox("Corda: " & corda & vbCrLf & vbCrLf & _
"Angulo: " & cadaAnguloInterno & " Graus")

End Sub
End Class

posta aí uma imagem das medidas que queres saber... não é que te possa ajudar mas fiquei curioso!!! fiquei sem perceber na mesma...

Edited by vikcch
Posted

Olá vikcch

Para perceberes a ideia aqui deixo uma imagem

http://img11.imageshack.us/img11/6617/npj.gif

a ideia é apresentar o valor do angulo em graus e minutos (não me interessa a parte decimal do grau, mas sim os minutos correspondentes) assim como o valor da corda em função da divisão que se pretende.

O código que mostras serve em parte e vou adapta-lo, pois faltava-me a referencia Math

Obrigado pela atenção

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.