Results 1 to 8 of 8

Thread: [RESOLVED] crossword answer vb6

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    9

    Resolved [RESOLVED] crossword answer vb6

    Hello everyone
    I am trying to make a program for my girlfriend who can send her crossword answer to a magazine she subscribes to and there are 25 answers and then you can also send answers for me and others but my problem is that I try to run through a index / array but it does not work can anyone help me in advance thanks

    this my code

    Option Explicit

    Private Declare Sub Sleep Lib "kernel32" (ByVal nMilliseconds As Long)

    'THIS DO NOT WORK
    Private Sub Command1_Click()
    Dim oIE As Object
    Dim URL As String

    Dim Ctrl As Control
    Dim Count As Long
    Set oIE = CreateObject("InternetExplorer.Application")
    URL = "https://dk-crossword-prod.aws.aller.com/sites/familiejournal/336"
    oIE.Visible = True
    oIE.navigate (URL)

    Do While oIE.readyState <> 4 And oIE.Busy
    DoEvents
    Loop
    For Count = 5641 To 5665

    For Each Ctrl In Me.Controls

    If TypeName(Ctrl) = "TextBox" Then

    oIE.document.All.Item("tasks[" & (Count) & "]").Value = Ctrl.Text

    End If

    Next

    Next Count

    Sleep 1000 'wait 1 sec before
    oIE.document.Forms(0).submit

    End Sub

    'THIS WORKS but can make this code smaller
    Private Sub Command2_Click()

    Dim oIE As Object
    Dim URL As String

    Dim Ctrl As Control
    Dim Count As Long
    Set oIE = CreateObject("InternetExplorer.Application")
    URL = "https://dk-crossword-prod.aws.aller.com/sites/familiejournal/336"
    oIE.Visible = True
    oIE.navigate (URL)

    Do While oIE.readyState <> 4 And oIE.Busy
    DoEvents
    Loop


    oIE.document.All.Item("tasks[5641]").Value = textbox(1).Text
    oIE.document.All.Item("tasks[5642]").Value = textbox(2).Text
    oIE.document.All.Item("tasks[5643]").Value = textbox(3).Text
    oIE.document.All.Item("tasks[5644]").Value = textbox(4).Text
    oIE.document.All.Item("tasks[5645]").Value = textbox(5).Text
    oIE.document.All.Item("tasks[5646]").Value = textbox(6).Text
    oIE.document.All.Item("tasks[5647]").Value = textbox(7).Text
    oIE.document.All.Item("tasks[5648]").Value = textbox(8).Text
    oIE.document.All.Item("tasks[5649]").Value = textbox(9).Text
    oIE.document.All.Item("tasks[5650]").Value = textbox(10).Text
    oIE.document.All.Item("tasks[5651]").Value = textbox(11).Text
    oIE.document.All.Item("tasks[5652]").Value = textbox(12).Text
    oIE.document.All.Item("tasks[5653]").Value = textbox(13).Text
    oIE.document.All.Item("tasks[5654]").Value = textbox(14).Text
    oIE.document.All.Item("tasks[5655]").Value = textbox(15).Text
    oIE.document.All.Item("tasks[5656]").Value = textbox(16).Text
    oIE.document.All.Item("tasks[5657]").Value = textbox(17).Text
    oIE.document.All.Item("tasks[5658]").Value = textbox(18).Text
    oIE.document.All.Item("tasks[5659]").Value = textbox(19).Text
    oIE.document.All.Item("tasks[5660]").Value = textbox(20).Text
    oIE.document.All.Item("tasks[5661]").Value = textbox(21).Text
    oIE.document.All.Item("tasks[5662]").Value = textbox(22).Text
    oIE.document.All.Item("tasks[5663]").Value = textbox(23).Text
    oIE.document.All.Item("tasks[5664]").Value = textbox(24).Text
    oIE.document.All.Item("tasks[5665]").Value = textbox(25).Text







    Sleep 1000 'wait 1 sec before
    oIE.document.Forms(0).submit

    End Sub
    Attached Files Attached Files
    Last edited by megabitdk; Aug 29th, 2021 at 12:37 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,704

    Re: crossword answer vb6

    What do you mean by "it does not work" ?

    You need to be a bit more detailed as to what problem you are having.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    9

    Re: crossword answer vb6

    The problem is that Commandbutton1 goes through each textbox on the web form 25 times for each textbox and ends up putting the text from the textbox (1) .Text in all textboxes on the web form but I want it to do just like commandbutton2

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,449

    Re: crossword answer vb6

    you could try like
    Code:
    For Count = 1 To 25
           oIE.document.All.Item("tasks[" & (Count + 5640) & "]").Value = me.controls("textbox" & count).text
    Next Count
    no need for double loops, which was causing a problem
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    9

    Re: crossword answer vb6

    get a runtime error 730
    Control 'Textbox1' not found

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    8,025

    Re: crossword answer vb6

    MAYBE westconn1's code MIGHT be this:???

    Code:
    For Count = 1 To 25
           oIE.document.All.Item("tasks[" & (Count + 5640) & "]").Value = me.controls("textbox(" & count & ").text)"
    Next Count
    Sam I am (as well as Confused at times).

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2021
    Posts
    9

    Re: crossword answer vb6

    I got it
    For Count = 1 To 25
    oIE.document.All.Item("tasks[" & (Count + 5640) & "]").Value = Me.Controls("textbox")(Count).Text
    Next Count

    thanks you for the help guys

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,449

    Re: [RESOLVED] crossword answer vb6

    oops an array of textboxes, glad you got it to work
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width