Julia Posted March 12, 2009 at 12:29 PM Report Share #250221 Posted March 12, 2009 at 12:29 PM Boa Tarde, eu sou a julia e sou estudante de uma turma de programação. A minha duvida é a seguinte: Eu tenho uma variavel com este valor:"1&Euro=1,2768" e o valor vai mudando todos os dias. Já sei como metelo a actualizar porq tive aqui a ver uns posts. Agora é o seguinte, eu preciso de fazer um conversor, logo vou precisar de ficar apenas com o valor 1,2768 numa variavel para poder fazer a conta. Alguem me pode ajudar? Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 12:39 PM Report Share #250224 Posted March 12, 2009 at 12:39 PM Estou no bloco de notas mas tenta: Dim intTemp as Integer dim valEuro as Double intTemp = variavelQueTens.IndexOf("&Euro=") valEuro = cdbl(variavelQueTens.Substring(intTemp + 5)) There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 12:41 PM Author Report Share #250226 Posted March 12, 2009 at 12:41 PM cdbl é o que? Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 12:43 PM Report Share #250227 Posted March 12, 2009 at 12:43 PM Converte para double um objecto 🙂 Uma alteraçao no codigo que dei: Dim intTemp as Integer dim valEuro as Double intTemp = variavelQueTens.IndexOf("&Euro=") valEuro = cdbl(variavelQueTens.Substring(intTemp + 6)) There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 12:57 PM Author Report Share #250235 Posted March 12, 2009 at 12:57 PM "A conversão da cadeia "ro; = 1.2786 " para o tipo 'Double' não é válida." Deve ter valores a mais né? Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 01:00 PM Report Share #250239 Posted March 12, 2009 at 01:00 PM Dim intTemp as Integer dim valEuro as Double intTemp = variavelQueTens.IndexOf("=") valEuro = cdbl(variavelQueTens.Substring(intTemp + 1)) There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 01:03 PM Author Report Share #250241 Posted March 12, 2009 at 01:03 PM Eu tinha feito em vez de ter mudado o indexOf aumenti o nr... meti +12. Deu, mas o . vai-se embora... preciso do ponto! devo de ter que converter pa Long nao double. Digo eu! Link to comment Share on other sites More sharing options...
jpaulino Posted March 12, 2009 at 01:03 PM Report Share #250243 Posted March 12, 2009 at 01:03 PM Só uma sugestão para ser mais à .NET e não utilizando as funções antigas, substituis o CDbl() por Double.Parse() Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 01:57 PM Author Report Share #250255 Posted March 12, 2009 at 01:57 PM eu preciso de ficar com o . :S ? Link to comment Share on other sites More sharing options...
jpaulino Posted March 12, 2009 at 02:01 PM Report Share #250257 Posted March 12, 2009 at 02:01 PM eu preciso de ficar com o . :S ? Então não é uma valor ? Só tens de alterar o formato de visualização utilizando FormatCurrency() Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 02:07 PM Author Report Share #250260 Posted March 12, 2009 at 02:07 PM Preciso, prq depois vou precisar desse valor! Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 02:13 PM Author Report Share #250263 Posted March 12, 2009 at 02:13 PM para fazer uma conta! por exemplo 1*valor da var (1.2768) Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 02:23 PM Report Share #250266 Posted March 12, 2009 at 02:23 PM Isto testei com o exemplo que deste e funcionou: Dim strTexto As String Dim dblValue As Double strTexto = "1&Euro=1,2768" strTexto = strTexto.Substring(strTexto.IndexOf("=") + 1) dblValue = Double.Parse(strTexto) Agora retiras e o strTexto ne 🙂 There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 02:34 PM Author Report Share #250270 Posted March 12, 2009 at 02:34 PM tão, mas ai já tou a dizer que strTexto vai ser igual 1&Euro=1,2768 e nao pode... tenho de ir tira-lo no texto, prq tá sempre a actualizar! Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 02:41 PM Author Report Share #250273 Posted March 12, 2009 at 02:41 PM Dim strTaxaEuro As String Dim intTemp As Integer Dim regex As New Regex("\s{2,}") var_semTAGS = regex.Replace(var_semTAGS.Trim(), " ") intTemp = var_semTAGS.IndexOf("1 €") strTaxaEuro = var_semTAGS.Substring(intTemp) strTaxaEuro = strTaxaEuro.Substring(0, strTaxaEuro.IndexOf("USD")) Dim dblvalue As Double Dim strTexto As String strTexto = strTaxaEuro strTexto = strTexto.Substring(strTexto.IndexOf("=") + 1) dblvalue = Double.Parse(strTexto) TextBox2.Text = dblvalue End Sub End Class Nao me devolve o valor com a , ou o . wtv! Link to comment Share on other sites More sharing options...
Julia Posted March 12, 2009 at 02:58 PM Author Report Share #250278 Posted March 12, 2009 at 02:58 PM Resolvido, tinha de fazer replace do . pela ,! Dim strTexto As String Dim dblvalue As Double strTexto = strTaxaEuro strTexto = strTexto.Substring(strTexto.IndexOf("=") + 1) strTexto = strTexto.Replace(".", ",") dblvalue = Double.Parse(strTexto) TextBox2.Text = dblvalue Link to comment Share on other sites More sharing options...
Hellblazer Posted March 12, 2009 at 03:02 PM Report Share #250280 Posted March 12, 2009 at 03:02 PM lol eu tinha deixado a nota a dizer que o strTexto teria de ser retirado para por a variavel com o valor 🙂 There are two ways to write error-free programs; only the third one works. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now