| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
matrix problems
Hi.
I am trying to make a code that asks you to enter 13 different words. Its supposed to stop if you enter more or less. Also the same word cant be entered twice. Then its supposed to count how many times each letter is used. Any tips on how to fix my code? Code:
<SCRIPT type="text/vbscript" LANGUAGE="vbscript">
<!--
dim strInput, arrMatrise, i
strInput = inputBox ("Skriv inn 13 forskjellige ord: ")
arrMatrise = split(strInput," ")
if UBound(arrMatrise) > 12 then
alert "Du har skrevet inn flere enn 13 ord. Vennligst prøv på nytt."
exit function
end if
if UBound(arrMatrise) 12 then
alert "Du har skrevet inn færre enn 13 ord. Vennligst prøv på nytt"
exit function
end if
for i = UBound(arrMatrise) - 1 To 0 Step -1
for j = 0 To i if arrMatrise(j) > arrMatrise(j+1) then
temporary = arrMatrise(j+1)
arrMatrise(j+1) = arrMatrise(j)
arrMatrise(j) = temporary
end if
next
next
for i = UBound(arrMatrise) - 1 To 0 Step -1
for j = 0 To i
if arrMatrise(j) = arrMatrise(j+1) then
alert "Obs, du har brukt ett av ordene mer enn en gang. Vennligst prøv på nyttt"
exit function
end if
next
next
-->
</SCRIPT>
|
|
#2
|
||||
|
||||
|
that code you have looks like it should input for string, split it into words and sort it, expecting 13 different words. the basic logic is fine, and except obvious problems in the syntax (probably copy&paste problem) the code looks fine. so if you want us to help you fix, first let us know exactly what is wrong with the code. you get error? if so, post here the full error message and code causing it.
|
|
#3
|
|||
|
|||
|
I dont see those obvious problems you are talking about. I am fairly new in this, and I probably have forgotten something stupid.
My first problem is that it doesnt show up an input-box in the browser. And then I need some tips on how to make it show up a list that counts how many time each letter is put in. |
|
#4
|
||||
|
||||
|
oh, I thought you had working code you written or found somewhere. where did that code come from then?
anyway, if you want it would be client side you better use javascript - vbscript will work only for IE browsers and nowdays the other browsers are taking 10% of the market - not so minor anymore. please let us know exactly what you intend to do with this list of letters - if you want it saved in database for example, you'll have to use ASP code and it would be big difference in both code and approach. if you want it client side, let me know if you have basic programming skills and I can guide you through the needed steps to create such code in javascript... writing fully working code would take some time. |
|
#5
|
|||
|
|||
|
Me and another person have written that code. I have basic skills, but obvious holes in my knowledge
![]() I need it to be VBscript, its for a school assignment I am working on this. I dont need a database, I can just bubble sort these letters, but cant think of how to start doing this, my brain is kinda fried... |
|
#6
|
||||
|
||||
|
is it for web page at all or for stand-alone vbscript file (pure vbscript assignment)?
|
|
#7
|
|||
|
|||
|
its for a webpage. But the vbscript is the only thing on the webpage.
|
|
#8
|
||||
|
||||
|
so you really better use javascript, which will work on more browsers - vbscript is for IE only. if you insist on vbscript, you can achieve what you want by having array with 26 items, one item for each letter, loop through the words and use Asc(Mid(str, x, 1)) to get ascii value of each character in the string, thus finding its place in the array. when I'll have more time I'll give more code if you need.
|
|
#9
|
|||
|
|||
|
My only option is to use VBscript. Thats what the school project is about.
|
|
#10
|
||||
|
||||
|
ok, so use the way I suggested... let me know if you have problems I'll try to help but I can't give you full code. you'll have to do that yourself.
|
|
#11
|
|||
|
|||
|
ok I need help figuring out how to count these things.
this is what I got... and I can tell its wrong but not how to fix it ![]() Code:
for i = UBound(arrMatrise) - 1 To 0 Step -1 for j = 0 to i if arrMatrise(j) = arrMatrise Asc(Mid(str, x, 1)) then end if next |
|
#12
|
||||
|
||||
|
I have no idea what you try to do in those loops if you can explain I might be able to help.
|
|
#13
|
|||
|
|||
|
I am trying to do that thing you told me to.
Quote:
I am sorry but I am a newbie in this, and I have big holes in my knowledge... Changed it a bit now... Code:
for i = UBound(arrMatrise) - 0 To 26 for j = 0 to i document.write arrMatrise Asc(Mid(str, x, 1)) next next exit function |