Ir para conteúdo
Fórum Script Brasil

FMartins

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que FMartins postou

  1. Caros amigos,Sou novo aqui, necessito de ajuda. Se possível! No código abaixo que estou adaptando está dando "Erro em tempo de execução 9: Subscrito forna do intervalo" na linha GuardaValorX(IndiceX) = rs![ValorX]. Sei que tem haver com o vetor/array, já pesquisei muito aqui e fora e nada consegui. Sei que para vocês isso é um café pequeno. Este código ler uma tabela, faz alguns comparativos/testes e grava em um campo.Alguém pode me iluminar nesta tarefa?Private Sub Comando10_Click()Dim db As DatabaseDim rs As DAO.RecordsetDim rs2 As DAO.RecordsetDim rsV As DAO.RecordsetSet db = CurrentDb()Dim contaReg As IntegerSet rs = db.OpenRecordset("SELECT * FROM [ValorMoedaY]")Set rsV = db.OpenRecordset("ValorMoedaY")contaReg = rsV.RecordCount'contaReg = rs.RecordCountDim AcumulaX As IntegerDim DescAcumulaX As IntegerDim GuardaValorX(24) As IntegerDim IndiceX As IntegerDim IndiceAntX As IntegerAcumulaX = 0DescAcumulaX = 0IndiceX = 0IndiceAntX = 0MsgBox "NÚMERO DE REGISTROS DA TABELA VALORMOEDAY: " & contaRegDo While Not rs.EOF rs.Edit IndiceX = IndiceX + 1 AcumulaX = AcumulaX + rs![ValorX] If IndiceX = 15 Then rs("CalculoValor") = AcumulaX / 14 End If If IndiceX > 15 Then IndiceAntX = IndiceX - 14 DescAcumulaX = AcumulaX - GuardaValorX(IndiceAntX) rs("CalculoValor") = DescAcumulaX / 14 End If 'MsgBox "IndiceX: " & IndiceX & " AcumulaX: " & AcumulaX & " IndiceAntX: " & IndiceAntX & " DescAcumulaX: " & DescAcumulaX & " GuardaValorX: " & GuardaValorX(IndiceAntX) GuardaValorX(IndiceX) = rs![ValorX] '<<<<<<<----------<<<<---------------------- é aqui -------<<<<------------- é aqui -------<<<<-------- rs.Update rs.Requery rs.MoveNextLooprs.CloseSet rs = Nothingrs2.CloseSet rs2 = Nothingdb.CloseSet db = NothingMsgBox "Cálculo concluído com sucesso...Tecle ENTER"'MsgBox "TERMINADO..."Exit Subtrata_erro: Call MsgBox("Erro nº " & Err.Number & " - " & Err.Description)'MsgBox "Cálculo concluído com sucesso..."End Sub Muito obrigado. Abraços
×
×
  • Criar Novo...