Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Array prob with VBscript

- - - - -

  • Please log in to reply
4 replies to this topic

#1
darph

darph

    Member

  • Member
  • PipPip
  • 153 posts
Hi

i´ve got the problem with a array i will print out only the min number of an entry.
so when i search for the number 0 i will only get 0
and when i search 100 i will get 44

but now i get the hole line of 0 or 100
i know i can delete the other entries but that is not the way i have to use.
can me help somebody.

thx for your help

darph

<script Language = "VBSCRIPT">

	Dim Sickerwasser_Links_ls(201)
	
	Sickerwasser_Links_ls(0) = 0
	Sickerwasser_Links_ls(1) = 0
	Sickerwasser_Links_ls(2) = 0
	Sickerwasser_Links_ls(3) = 0
	Sickerwasser_Links_ls(4) = 0
	Sickerwasser_Links_ls(5) = 0
	Sickerwasser_Links_ls(6) = 0
	Sickerwasser_Links_ls(7) = 0
	Sickerwasser_Links_ls(8) = 0
	Sickerwasser_Links_ls(9) = 0
	Sickerwasser_Links_ls(10) = 0
	Sickerwasser_Links_ls(11) = 0
	Sickerwasser_Links_ls(12) = 0
    Sickerwasser_Links_ls(13) = 0
	Sickerwasser_Links_ls(14) = 0
	Sickerwasser_Links_ls(15) = 0
	Sickerwasser_Links_ls(16) = 10
	Sickerwasser_Links_ls(17) = 10
	Sickerwasser_Links_ls(18) = 20
	Sickerwasser_Links_ls(19) = 20
	Sickerwasser_Links_ls(20) = 30
	Sickerwasser_Links_ls(21) = 30
	Sickerwasser_Links_ls(22) = 30
	Sickerwasser_Links_ls(23) = 40
	Sickerwasser_Links_ls(24) = 40
	Sickerwasser_Links_ls(25) = 40
	Sickerwasser_Links_ls(26) = 40
	Sickerwasser_Links_ls(27) = 50
	Sickerwasser_Links_ls(28) = 50
	Sickerwasser_Links_ls(29) = 50
	Sickerwasser_Links_ls(30) = 50
	Sickerwasser_Links_ls(31) = 60
	Sickerwasser_Links_ls(32) = 60
	Sickerwasser_Links_ls(33) = 60
	Sickerwasser_Links_ls(34) = 70
	Sickerwasser_Links_ls(35) = 70
	Sickerwasser_Links_ls(36) = 70
	Sickerwasser_Links_ls(37) = 70
	Sickerwasser_Links_ls(38) = 80
	Sickerwasser_Links_ls(39) = 80
	Sickerwasser_Links_ls(40) = 80
	Sickerwasser_Links_ls(41) = 90
	Sickerwasser_Links_ls(42) = 90
	Sickerwasser_Links_ls(43) = 90
	Sickerwasser_Links_ls(44) = 100
	Sickerwasser_Links_ls(45) = 100
	Sickerwasser_Links_ls(46) = 100
	Sickerwasser_Links_ls(47) = 110
	Sickerwasser_Links_ls(48) = 110
	Sickerwasser_Links_ls(49) = 120
	Sickerwasser_Links_ls(50) = 120
	Sickerwasser_Links_ls(51) = 120
	Sickerwasser_Links_ls(52) = 130
	Sickerwasser_Links_ls(53) = 130
	Sickerwasser_Links_ls(54) = 140
	Sickerwasser_Links_ls(55) = 140
	Sickerwasser_Links_ls(56) = 140
	Sickerwasser_Links_ls(57) = 150
	Sickerwasser_Links_ls(58) = 150
	Sickerwasser_Links_ls(59) = 160
	Sickerwasser_Links_ls(60) = 160
	Sickerwasser_Links_ls(61) = 160
	Sickerwasser_Links_ls(62) = 170
	Sickerwasser_Links_ls(63) = 170
	Sickerwasser_Links_ls(64) = 180
	Sickerwasser_Links_ls(65) = 180
	Sickerwasser_Links_ls(66) = 190
	Sickerwasser_Links_ls(67) = 190
	Sickerwasser_Links_ls(68) = 190
	Sickerwasser_Links_ls(69) = 200
	Sickerwasser_Links_ls(70) = 200
	Sickerwasser_Links_ls(71) = 210
	Sickerwasser_Links_ls(72) = 210
	Sickerwasser_Links_ls(73) = 220
	Sickerwasser_Links_ls(74) = 220
	Sickerwasser_Links_ls(75) = 230
	Sickerwasser_Links_ls(76) = 230
	Sickerwasser_Links_ls(77) = 240
	Sickerwasser_Links_ls(78) = 240
	Sickerwasser_Links_ls(79) = 250
	Sickerwasser_Links_ls(80) = 250
	Sickerwasser_Links_ls(81) = 260
	Sickerwasser_Links_ls(82) = 260
	Sickerwasser_Links_ls(83) = 270
	Sickerwasser_Links_ls(84) = 270
	Sickerwasser_Links_ls(85) = 280
	Sickerwasser_Links_ls(86) = 280
	Sickerwasser_Links_ls(87) = 290
	Sickerwasser_Links_ls(88) = 290
	Sickerwasser_Links_ls(89) = 300
	Sickerwasser_Links_ls(90) = 300
	Sickerwasser_Links_ls(91) = 310
	Sickerwasser_Links_ls(92) = 310
	Sickerwasser_Links_ls(93) = 320
	Sickerwasser_Links_ls(94) = 320
	Sickerwasser_Links_ls(95) = 330
	Sickerwasser_Links_ls(96) = 330
	Sickerwasser_Links_ls(97) = 340
	Sickerwasser_Links_ls(98) = 340
	Sickerwasser_Links_ls(99) = 350
	Sickerwasser_Links_ls(100) = 350
	Sickerwasser_Links_ls(101) = 360
	Sickerwasser_Links_ls(102) = 370
	Sickerwasser_Links_ls(103) = 370
	Sickerwasser_Links_ls(104) = 380
	Sickerwasser_Links_ls(105) = 380
	Sickerwasser_Links_ls(106) = 390
	Sickerwasser_Links_ls(107) = 390
	Sickerwasser_Links_ls(108) = 400
	Sickerwasser_Links_ls(109) = 400
	Sickerwasser_Links_ls(110) = 410
	Sickerwasser_Links_ls(111) = 420
	Sickerwasser_Links_ls(112) = 420
	Sickerwasser_Links_ls(113) = 430
	Sickerwasser_Links_ls(114) = 430
	Sickerwasser_Links_ls(115) = 440
	Sickerwasser_Links_ls(116) = 440
	Sickerwasser_Links_ls(117) = 450
	Sickerwasser_Links_ls(118) = 460
	Sickerwasser_Links_ls(119) = 460
	Sickerwasser_Links_ls(120) = 470
	Sickerwasser_Links_ls(121) = 470
	Sickerwasser_Links_ls(122) = 480
	Sickerwasser_Links_ls(123) = 490
	Sickerwasser_Links_ls(124) = 490
	Sickerwasser_Links_ls(125) = 500
	Sickerwasser_Links_ls(126) = 500
	Sickerwasser_Links_ls(127) = 510
	Sickerwasser_Links_ls(128) = 520
	Sickerwasser_Links_ls(129) = 520
	Sickerwasser_Links_ls(130) = 530
	Sickerwasser_Links_ls(131) = 540
	Sickerwasser_Links_ls(132) = 540
	Sickerwasser_Links_ls(133) = 550
	Sickerwasser_Links_ls(134) = 550
	Sickerwasser_Links_ls(135) = 560
	Sickerwasser_Links_ls(136) = 570
	Sickerwasser_Links_ls(137) = 580
	Sickerwasser_Links_ls(138) = 580
	Sickerwasser_Links_ls(139) = 590
	Sickerwasser_Links_ls(140) = 590
	Sickerwasser_Links_ls(141) = 600
	Sickerwasser_Links_ls(142) = 610
	Sickerwasser_Links_ls(143) = 610
	Sickerwasser_Links_ls(144) = 620
	Sickerwasser_Links_ls(145) = 630
	Sickerwasser_Links_ls(146) = 630
	Sickerwasser_Links_ls(147) = 640
	Sickerwasser_Links_ls(148) = 650
	Sickerwasser_Links_ls(149) = 660
	Sickerwasser_Links_ls(150) = 660
	Sickerwasser_Links_ls(151) = 670
	Sickerwasser_Links_ls(152) = 680
	Sickerwasser_Links_ls(153) = 680
	Sickerwasser_Links_ls(154) = 690
	Sickerwasser_Links_ls(155) = 700
	Sickerwasser_Links_ls(156) = 700
	Sickerwasser_Links_ls(157) = 710
	Sickerwasser_Links_ls(158) = 720
	Sickerwasser_Links_ls(159) = 730
	Sickerwasser_Links_ls(160) = 740
	Sickerwasser_Links_ls(161) = 740
	Sickerwasser_Links_ls(162) = 750
	Sickerwasser_Links_ls(163) = 760
	Sickerwasser_Links_ls(164) = 760
	Sickerwasser_Links_ls(165) = 770
	Sickerwasser_Links_ls(166) = 780
	Sickerwasser_Links_ls(167) = 780
	Sickerwasser_Links_ls(168) = 790
	Sickerwasser_Links_ls(169) = 800
	Sickerwasser_Links_ls(170) = 810
	Sickerwasser_Links_ls(171) = 820
	Sickerwasser_Links_ls(172) = 820
	Sickerwasser_Links_ls(173) = 830
	Sickerwasser_Links_ls(174) = 840
	Sickerwasser_Links_ls(175) = 850
	Sickerwasser_Links_ls(176) = 860
	Sickerwasser_Links_ls(177) = 860
	Sickerwasser_Links_ls(178) = 870
	Sickerwasser_Links_ls(179) = 880
	Sickerwasser_Links_ls(180) = 890
	Sickerwasser_Links_ls(181) = 890
	Sickerwasser_Links_ls(182) = 900
	Sickerwasser_Links_ls(183) = 910
	Sickerwasser_Links_ls(184) = 920
	Sickerwasser_Links_ls(185) = 930
	Sickerwasser_Links_ls(186) = 930
	Sickerwasser_Links_ls(187) = 940
	Sickerwasser_Links_ls(188) = 950
	Sickerwasser_Links_ls(189) = 960
	Sickerwasser_Links_ls(190) = 970
	Sickerwasser_Links_ls(191) = 970
	Sickerwasser_Links_ls(192) = 980
	Sickerwasser_Links_ls(193) = 990
	Sickerwasser_Links_ls(194) = 1000
	Sickerwasser_Links_ls(195) = 1010
	Sickerwasser_Links_ls(196) = 1010
	Sickerwasser_Links_ls(197) = 1020
	Sickerwasser_Links_ls(198) = 1030
	Sickerwasser_Links_ls(199) = 1040
	Sickerwasser_Links_ls(200) = 1050

m = 0 // Wert was gesucht wird

Dim Array

For i  = 0 to 200
	If Sickerwasser_Links_ls(i) = m then

	Document.Write(i)

	End If
Next
</SCRIPT>

Posted Image
Never forget the Modding!!


How to remove advertisement from MSFN

#2
Mpak

Mpak

    Flame Monster

  • Member
  • Pip
  • 59 posts
Do you want to get "44,45,46" when you're looking for variables that have value '100'? (and receive "0,1,2,...,15" for '0' request?)

Try:
Dim A(1) As Integer, N as Integer, m as Integer

m = 100
N = 1

For I = 1 To 200
  If  Sickerwasser_Links_ls(i) = m then 
      A(N) = i
      N = N + 1
      ReDim Preserve A(1 to N)
  End If
Next I
You will get array A(N) with indexes of variables that store m.

#3
darph

darph

    Member

  • Member
  • PipPip
  • 153 posts
thx for your tip

but i think you misunderstood me

i mean i only want the first entry of the array

like i search 0 and only get 0 but at the moment i get 0,1,2,3,4....

so long

darph
Posted Image
Never forget the Modding!!

#4
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
Add 'Exit For' to your conditional statement, then when its true it will terminate the For..Next Loop.

For i  = 0 to 200
    If Sickerwasser_Links_ls(i) = m then
        Document.Write(i)
        Exit For
    End If
Next


#5
darph

darph

    Member

  • Member
  • PipPip
  • 153 posts
thx

i will test it and hope it will work :)

thx for the fast help

so long

darph
Posted Image
Never forget the Modding!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN