473,467 Members | 1,446 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

output variable contents into new text file

I am working on a prime number generator for sschool, but I jsut can't
seem to figure out how to write the contents of the variable MeSSage
into a new text file, Can someone help me?

the script is:
'================================================= =========================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript
4.0
'
'================================================= =========================

Dim Cntr, cnTr2, MeSSage, ModVal, OutCount, StartTime
Dim MaX

MeSSage = ""
OutCount = 4
StartTime = Now()

MaX = InputBox("Enter the highest number to reach when searching for
the prime numbers", "enter Max Number", 50)

'loop the value for count from 10 to the chosen number
For Cntr = 10 To MaX
'if cntr is odd counting in statement, else loop to next cntr value
If Cntr Mod 2 <0 Then
'set initial cntr2 value to 3
cnTr2 = 3
'while cntr is less than the value of cntr run statements
Do While cnTr2 < Cntr
'if cntr mod cntr2 =0, or a divisor is found lead loop to
go to next number
If Cntr Mod cnTr2 = 0 Then
'Exit do loop and move to next possible number
Exit Do
End If
'if cntr2 makes it to half of cntr without finding a match
call mess
If cnTr2 >= (Cntr / 2) Then
'call the module to append the numbers to the output
variable
Call MesS
Exit Do
End If
'go to the next possible number
cnTr2 = cnTr2 + 1
Loop
End If
Next

'if the prime number output has more than 669 numbers then you do not
want to display the numbers
If OutCount>669 Then
MeSSage = ""
Else
'Else display the numbers
MeSSage = MeSSage & vbCrLf & vbCrLf
End If

'Append the information to the end of the output message
MeSSage = MeSSage & "A total of " & OutCount & " prime numbers have
been found between 1 and " & MaX & "." & vbCrLf & vbCrLf & "The process
took " & DateDiff("s", StartTime, Now()) & " seconds."

'output the output MeSSage
'WScript.Echo MeSSage
Public Function MesS()

'If message has no numbers then start with the first 4 primes and
append the next prime
If MeSSage = "" Then
MeSSage = "1, 3, 5, 7, " & Cntr
Else
'Else add number To message
MeSSage = MeSSage & ", " & Cntr
End If

OutCount = OutCount + 1

End Function

Aug 18 '06 #1
0 1079

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: chuck amadi | last post by:
By the way list is there a better way than using the readlines() to > > >parse the mail data into a file , because Im using > > >email.message_from_file it returns > > >all the data i.e reads one...
4
by: Mike Conmackie | last post by:
Hi Folks, I've probably omitted something very basic but I have no idea what it might be. The results of my transformation _should_ be an xml file but all I get is the xml declaration...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
1
by: Aalok | last post by:
This is what i want to do. Read a text file as an input and based on that file, Create an outpu text file which saves the contents of the input file in a specifi format in the output file. I...
1
by: TJ | last post by:
I am very new to C# (this is my first real project), therefore please be patient if my question is considered being to newbie. I am modifying a program which takes a text file, does some...
4
by: Jon Slaughter | last post by:
I'm using eval to excute some mixed php and html code but I cannot debug it. I am essentially using filegetcontents to load up a php/html file and then inserting it into another php/html file and...
4
by: csandbach | last post by:
Hi, I'm new to PHP, im used to coding in asp, so please bare with me. What i would like is to output the result to a text file <?php $_ip = $_SERVER; echo "<b>Enter the IP or the domain name...
1
by: dwaterpolo | last post by:
Hi Everyone, I am trying to read two text files swY40p10t3ctw45.col.txt and solution.txt and compare them, the first text file has a bunch of values listed like: y y y y y y y
2
by: benn | last post by:
I need to output the contents of a struct variable (which internally has a bunch of ints, strings, other structs, etc) onto the screen (then ultimately out the com port). I don't mind a raw...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.