Write a function in VB

Updated on technology 2024-04-11
5 answers
  1. Anonymous users2024-02-07

    Parameter description: rndnumcount, the number of 6 digits; mysearchnum, the number to look for.

    private function searchnumcount(byval rndnumcount as integer, byval mysearchnum as integer) as integer

    dim i as integer '6-digit number.

    dim j as long 'A random 6-digit value.

    dim a as integer 'The 6-digit number of the current query.

    dim start as integer 'The starting location of the query.

    dim temp as integer 'Temporary location.

    dim length as integer'Look at the length of the number (1).

    redim marray(rndnumcount - 1) 'Define an array of parameter lengths.

    randomize 'Random number seeds.

    for i = 0 to rndnumcount - 1 'Assign a random 6-digit number to an array.

    j = clng(999999 * rnd + 100000)

    marray(i) = j

    nextfor a=0 to rndnumcount-1 'The number of occurrences of the number to be queried in the array.

    start=1

    length=len(mysearchnum)

    do temp=instr(start,marray(a),mysearchnum)

    if temp<>0 then

    searchnumcount = searchnumcount + 1

    start=temp+length

    else exit do

    end if

    loop next

    msgbox "The number you're looking for" +cstr(mysearchnum)+", appears"+cstr(rndnumcount)+"The number of 6-digit numbers is:"+cstr(searchnumcount)+"Times! "

    end function

  2. Anonymous users2024-02-06

    dim num as long

    num=0for i=1 to n

    for j=0 to 5

    if array(j) = the number you are looking for then num=num+1next j

    next i

    The value of num is the number of occurrences you are looking for.

  3. Anonymous users2024-02-05

    You first find the number of times a value appears in each array, and then add these values together, and that's it, to provide you with a little idea, which you should be able to do by looking at the VB tutorial.

  4. Anonymous users2024-02-04

    1,2,3,4...9 iterate over n arrays in turn.

    This algorithm is a bit slow, and you can look up some about finding algorithms!

  5. Anonymous users2024-02-03

    Write more**. Do a lot of online research. Ask others how to achieve it, and it will definitely be no problem, VB is very simple!

Related questions
11 answers2024-04-11

Insert 3 texts, 1 command

private sub form_load()= "1000" 'Blood volume. >>>More

14 answers2024-04-11

private sub command1_click()dim i as integer

dim sum as long >>>More

11 answers2024-04-11

Is there any raw data? What is the interface like? Where does the grade data come from?

11 answers2024-04-11

Upstairs ** is so long, it's still simple?

Speechless. I wrote one for you, this is really simple and practical, hehe! >>>More

6 answers2024-04-11

i=1,j=1:x(1,1)=x(0,0)+1+1=2i=1,j=2:x(1,2)=x(0,1)+1+2=3...

i=1,j=5:(x,5)=x(0,4)+1+6=6--- >>>More