Wrox Programmer Forums
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2008, 05:21 AM
Authorized User
 
Join Date: Jun 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Syntax error =(

Hello, I'm new in VB...
I have VB code but there is an error and I do not know how to fix it.
Here is the code:

str = request.Form("txtSearch");
length = request.Form("txtSearch.value.length");
str_fix = "";
first = 1;
final = "";
word = 0;

for i=0 to length do
     if i = length or str[i] = ' ' then
         if str[i] <> "" then
        path="form/document[(.,'<%= request.Form(" & str_fix & ")%>')]//*";
        if first = 0 then: final += ' ';
        first = 0;
        final += str_fix;
        str_fix = "";
        word ++;
         end if

         while str[i+1] = ' ' and i+1 < length do
             i++;
         wend

     else
    str_fix += str[i];
next

if word > 1 then: path="form/document[(.,'<%= request.Form(" & final & ")%>')]//*";



 
Old June 19th, 2008, 04:51 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

This is a syntax error. The colon specifies the end of a statement. So essentially you have something for VB to do if the test is true, but the something is unspecified. Use either:
Code:
    If word > 1 Then path = ...
or
Code:
    If word > 1 Then
        path = ...
    End If
    Same deal with "if first = 0 then: final += ' ';"

Plus, I don't follow your meaning here at all:
Code:
    While str[i + 1] = ' ' And i + 1 < length do
The interpreter would try to resolve "length do". but that doesn't mean anything. It makes "do" an argument of the Sub length(). But "length" is in a position where a value is needed for the comparison.
 
Old June 19th, 2008, 05:00 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I think Brian is wrong.

The syntax error is that you have a semicolon on the end of your statement!

C# and C++ and Java and JavaScript and C all use semicolons.

VB doesn't allow them.
 
Old June 19th, 2008, 05:02 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

And of course you can't use [...] in VB either.

If you want to write in C#, then write in C#. VB syntax is completely different.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM
Compile error: Syntax error: & Else without HELP Corey VB How-To 2 April 21st, 2006 03:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.