\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Simple Code


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
This is some homework code and I am just starting to learn the basics of VB. I am getting an comp. error on the filename and pathname lines and was wondering anyone could help with this.
\r\n
\r\nThe error simply reads expected expression and I am not sure how to deal with that. Thank you in advance for your help!
\r\n
\r\n
\r\n
\r\n
\r\nSub LULZ()
\r\n
\r\nfilename = Inputbox("Enter file name", , )
\r\npathname = inputbox("Enter path to file", , )
\r\n
\r\nmyfile = pathname + Filename
\r\n
\r\nOpen myfile For Input As #1
\r\n
\r\nn = 0
\r\nDo Until EOF(1) Or n >= 100
\r\nn = n + 1
\r\nInput #1, x
\r\nIf x > 2 Then
\r\nf = Cos(x)
\r\nElse
\r\nf = Tan(x)
\r\nEnd If
\r\n
\r\nWith Worksheet(1)
\r\n.Cells(n, 1).Value = x
\r\n.Cells(n, 2).Value = f
\r\nEnd With
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\nEnd Sub
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[1384782] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 07-23-2011, 12:43 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
webbone\'s Avatar\r\n\r\n
\r\n \r\n webbone\r\n webbone is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 07-23-2011, 12:26 AM
cfourt cfourt is offline
Newcomer
 
Join Date: Jul 2011
Posts: 1
Default Simple Code


This is some homework code and I am just starting to learn the basics of VB. I am getting an comp. error on the filename and pathname lines and was wondering anyone could help with this.

The error simply reads expected expression and I am not sure how to deal with that. Thank you in advance for your help!




Sub LULZ()

filename = Inputbox("Enter file name", , )
pathname = inputbox("Enter path to file", , )

myfile = pathname + Filename

Open myfile For Input As #1

n = 0
Do Until EOF(1) Or n >= 100
n = n + 1
Input #1, x
If x > 2 Then
f = Cos(x)
Else
f = Tan(x)
End If

With Worksheet(1)
.Cells(n, 1).Value = x
.Cells(n, 2).Value = f
End With






End Sub
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->