Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2003, 06:01 AM
AaronH64 AaronH64 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 AaronH64 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Do Loops.. Need lots of help

I need to setup 2 loops in each one of these Frames. This is for a school project.


Thank you.


I have been pulling my hair out over this thing so any help would be greatly appreciated.



The "ID" below is pulled from a SQL Server 2000 table. Tablename TBLOBJECTSA The column is ID.


CREATE TABLE tblobjectsa(
ID INT IDENTITY (1, 1) NOT NULL,
FileName VARCHAR(30),
FileSize VARCHAR(30),
FileData IMAGE,
ContentType VARCHAR(30),
Title VARCHAR(40),
t VARCHAR(10),
);


"ID" is an autonumber field in my table so it does not reset if an object is deleted. So if object ID 10 was deleted, the loops would still need to pull Object ID 9, 11, 12, 15 etc. I need these loops to pull the object ID's out of the table and use them to fill my loops. The users can add and remove objects at will, so the number of objects is always changing.


Here is a link to the site: URL

*You will get a red x on the left frame because you have to be signed in for that image to appear. No biggie.




>>Right Frame:<< My complete code is at the bottom.


**The first loop I need to make is for this code**

<BR> <BR>
<IMG height=96 alt="" src="Objects8.asp?ID=<%=9%>" width=150 name=Objects8.asp?ID=<%=9%>>

The ID represents the column ID from my Image in my SQL Table. This table is called TBLOBJECTSA. Also ID is an Integer. So I will need a loop that pulls the ID from the table and inserts it. Plus I need one of these entries for every object in my DB.

Example:

If I had two objects my code would look like this:

<BR> <BR>
<IMG height=96 alt="" src="Objects8.asp?ID=<%=9%>" width=150 name=Objects8.asp?ID=<%=9%>>

<BR> <BR>
<IMG height=96 alt="" src="Objects8.asp?ID=<%=10%>" width=150 name=Objects8.asp?ID=<%=10%>>



**The second loop I need for the right frame is for this code**

SET_DHTML(CURSOR_CROSSHAIR, "Objects8.asp?ID=<%=9%>"+VERTICAL+HORIZONTAL);


If there was more than one object, the code would look like this:

SET_DHTML(CURSOR_CROSSHAIR, "Objects8.asp?ID=<%=9%>"+VERTICAL+HORIZONTAL, "Objects8.asp?ID=<%=10%>"+VERTICAL+HORIZONTAL);



>>Left Frame:<<

The 2 loops for this frame are almost Identicle to the right frame's.

**Left Frame Loop 1**

I need to loop:

<DIV ID="myDiv"
STYLE="position: absolute; left: 200px; top: 200px;">
<IMG height=96 alt="" src="Objects8.asp?ID=<%=9%>" width=150 name=Objects8.asp?ID=<%=9%>></DIV>

If there were more than 1 object it would look like this:

<DIV ID="myDiv"
STYLE="position: absolute; left: 200px; top: 200px;">
<IMG height=96 alt="" src="Objects8.asp?ID=<%=9%>" width=150 name=Objects8.asp?ID=<%=9%>></DIV>

<DIV ID="myDiv"
STYLE="position: absolute; left: 200px; top: 200px;">
<IMG height=96 alt="" src="Objects8.asp?ID=<%=10%>" width=150 name=Objects8.asp?ID=<%=10%>></DIV>

The second loop is for this code:

SET_DHTML(CURSOR_MOVE, RESIZABLE, "Objects8.asp?ID=<%=9%>", "comment"+NO_DRAG);

I assume this would be the same loop that is on the right frame.




Here is my code:

*******************RIGHT FRAME******************************


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Drag & Drop</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center">
<SCRIPT src="wz_dragdrop.js" type=text/javascript></SCRIPT><font color="#003399">
<font size="+2" face="Times New Roman, Times, serif"><strong>Object Bank</font></font>
<hr>

<BR> <BR>
<IMG height=96 alt="" src="Objects8.asp?ID=<%=9%>" width=150 name=Objects8.asp?ID=<%=9%>>


<SCRIPT type=text/javascript>

SET_DHTML(CURSOR_CROSSHAIR, "Objects8.asp?ID=<%=9%>"+VERTICAL+HORIZONTAL);

// Combining VERTICAL and HORIZONTAL is the easiest way to fix elements

function my_PickFunc()
{
if (parent.left)
{
parent.left.dd.elements[dd.obj.name].copy();
// Creates a copy of the clicked image's brother in the left frame

var copieslength = parent.left.dd.elements[dd.obj.name].copies.length;
// Current number of copies

parent.left.dd.elements[dd.obj.name].copies[copieslength-1].moveTo (parent.left.dd.elements[dd.obj.name].x + 10*copieslength, parent.left.dd.elements[dd.obj.name].y + 10*copieslength);
// Offsets the current copy by 10 px from the previous copy.

var comment = parent.left.dd.elements.comment;
if (!comment.visible) comment.show();
}
}
// This function overrides it's namesake in wz_dragdrop.js.
//-->
</SCRIPT>
</div>
</body>
</html>


******************************LEFT FRAME*****************************************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Drag & Drop</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<BODY border="0" bgcolor="#000000" style="MARGIN: 0px:" top margin="0" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">

<a href="homescreen.asp" target="_parent"><img src=home.jpg border=0 alt="Cyber Artist Homescreen"></a>

<div align="center">

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
document.write('<form><input type=button value="Clear Canvas" onClick="history.go()"></form>')
// End -->
</script>
</div>


<center><img src="Paintings8.asp?ID=<% response.write SESSION("Svariable")%>" alt="your image" border="0"> </center>

<SCRIPT src="wz_dragdrop.js" type=text/javascript></SCRIPT>

<DIV ID="myDiv"
STYLE="position: absolute; left: 200px; top: 200px;">
<IMG height=96 alt="" src="Objects8.asp?ID=<%=9%>" width=150 name=Objects8.asp?ID=<%=9%>></DIV>



<SCRIPT type=text/javascript>
<!--
SET_DHTML(CURSOR_MOVE, RESIZABLE, "Objects8.asp?ID=<%=9%>", "comment"+NO_DRAG);

for (var i = 0; i < dd.elements.length; i++)
{
dd.elements[i].hide();
}
// images should not be visible initially
//-->
</SCRIPT>


</body>
</html>



**************************************END CODE***********************************************************************

Reply With Quote
  #2  
Old October 13th, 2003, 09:01 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,176 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 42 m 4 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
are you doing it like this?
<%
Do Blah until BlahBlah = intSomeNumber
%>
<HTML STUFF IN TAGS HERE>
<...
...>
<%
Loop
%>

(just the general format)

or are you doing it like this

<%
Do Blah until BlahBlah = intSomeNumber
response.write "<HTML STUFF IN TAGS HERE><.......>"
Loop

The second way would be the preferred method.
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old October 13th, 2003, 11:05 AM
AaronH64 AaronH64 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 AaronH64 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried something like this with no luck. To to be honest I suck at Do loops and arrays. Plus I am fairly new to VB and VB script.



<%
Do Blah until BlahBlah = intSomeNumber
%>
<HTML STUFF IN TAGS HERE>
<...
...>
<%
Loop
%>


Can you even use VB with "<% %>" within a <SCRIPT> </SCRIPT> tag?

Right now I am willing to try anything.

Last edited by AaronH64 : October 13th, 2003 at 11:09 AM.

Reply With Quote
  #4  
Old October 13th, 2003, 11:45 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,176 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 42 m 4 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
What exactly is the problem that you're having? When I went to the site, it seemed to work OK, except for the fact that any click (single, double, whatever) made the graphic drop into the left panel.

Reply With Quote
  #5  
Old October 13th, 2003, 11:54 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,176 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 42 m 4 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
let me say this though. If you are going to control HTML output with scripting, then you really need to use the document.write method. You can do something like this

document.write "<FONT COLOR =RED SIZE = 6>HI AARON</FONT>"

and the browser (granted that it is an IE compatible one) will recognize the output of the script as HTML, and will mark up the text accordingly. You can even concatenate strings together to make the entire page dynamically, and then "spit it out" to the browser. something like this

Code:
dim StrHTML as string
strHTML = "<FONT SIZE = 6 COLOR = RED>Hello, Aaron</FONT><BR><BR>"
strHTML = strHTML & " Welcome Back to our store"

document.write strHTML

Reply With Quote
  #6  
Old October 13th, 2003, 12:11 PM
AaronH64 AaronH64 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 AaronH64 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Right now it works because I added "Objects8.asp?ID=<%=9%>" to my code in every occurence of where to add the image filename. (IE. "Eienstein.gif" would work if the image was saved to the root drive and not in the db)

The admin of the application needs to have the ability to add additional objects to the object bank without having to write code. So the coding (in both frames) needs to change as more objects are added.

The way the page needs to work is when the user clicks objects in the object bank they appear on the canvas. The user then can move the objects around and hold down the shift key and resize them.

Since I have "Objects8.asp?ID=<%=9%>" coded in, it pulls the single object from my DB. This is not pulling all the objects from the DB.

I need something like:

SQLSTRING = SELECT ID from TBLUSERSA
ID = CONN.EXECUTE(SQLSTRING)

DO UNTIL ID.EOF

etc etc

Then the ID needs to be used as the "ID" in Objects8.asp?ID=<%=9%> throughout the pages.

I tried to do a DO UNTIL LOOP like:

DO UNTIL ID.EOF
Objects8.asp?ID=<%response.write("ID")%>
ID.MOVENEXT
LOOP etc etc etc

and it pulled the objects from the object table, but the rest of the code did not work.

does response.write("ID") make it a string and not an integer?


Like I said.. I am new to this. I have completely relearned VB in the past week.





If it helps, my code for Objects8.asp is the following:


*********************OBJECTS8.ASP***********

<%
'Read in ID from querystring
Dim ID
ID = Request.QueryString("ID")

'Select picture from SQL server
Dim Conn, RS, SQL
SQL = "SELECT filedata FROM tblobjectsa WHERE ID = " & ID

'Make db connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DATA SOURCE=111.111.1.11;Provider=sqloledb;database=12345;UID=UID;PWD=password;"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, Conn

'Set the ContentType to image/jpg
Response.ContentType = "image/jpg"

'Use Response.BinaryWrite to output the image
Response.BinaryWrite RS("filedata")

'Clean up...
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>


***************END OBJECTS8.ASP*************

Last edited by AaronH64 : October 13th, 2003 at 01:10 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Do Loops.. Need lots of help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway