Why don’t my vectors store the information in my textbox ? I’ve tried everything

Asked

Viewed 19 times

0

Sub Email()
Dim z, i, count As Integer
Dim r(100000), s(100000), t(100000), u(100000), v(100000), w(100000) As String
Dim a As String
a = txtDataDOU.Value
count = 0
For i = 1 To z
    If Cells(i, 4).Value = a Then
    r(i) = txtDataDespacho
    s(i) = txtNumeroDespacho.Value
    t(i) = txtDataDOU.Value
    u(i) = txtOrdem.Value
    v(i) = txtLink.Value
    w(i) = txtResumo.Value
    count = count + 1
    End If
Next
txtDataDespacho.Value = ""
txtNumeroDespacho.Value = ""
txtDataDOU.Value = ""
txtOrdem.Value = ""
txtLink.Value = ""
txtResumo.Value = ""
Dim objeto_outlook As Outlook.Application
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application") 'Objeto para Outlook
Set OutMail = OutApp.CreateItem(0) 'Objeto para email dentro do Outlook
For i = 1 To count + 1
With OutMail
.display
.to = Cells(14, 1).Value
.Subject = "Atos do dia " & a
.Body = "Daespacho N° " & r(count) & vbNewLine & vbNewLine & w(i) & vbNewLine & vbNewLine & " Link: " & v(i)
End With
Next
MsgBox "E-mail enviado com sucesso !!!", vbInformation, "Informação"
End Sub
  • Two questions: did you set the value of Z? Without this, it will probably be 0 and the loop will not iterate once.

    1. That one Sub Email call is in which module? If you are in the module of the same form that contains the Textbox all right, but if you’re in a different module, you have a scope problem. In this case, to reference the contents of the text boxes it will be necessary to set a variable with the object Form and use minhaVariavel.txtDataDespacho.Value.
  • 1

    Thank you, I’ve solved my problem.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.