Skip to main content
GameDev.net gamedev.net
🔒 Locked

This is such a Noob ? that im shamed to ask but...

Started by Rockjs Jan 18, 2006 at 2:47 PM 3 replies 700+ views
Original Post
Rockjs
Rockjs
Well 1st, /wave hey all. Im new to the world of game programming (well programming altogether) I have studied VB a bit in college but havent touched on it since (incase you are wondering, that was like 2 years ago). Anyhow, here is my question; I am currently writing a program to assist me in my job. Yea i know what your gunna say "this isnt a game." Well i had to put off the game tutorial that i was working on (from the book "Game Programming For Teens" by Jonathan S. Harbour) to get this program done. I am writing a program that will enter data to a database using a GUI made in vb. I am trying to take data from a list and send it to the database. The problem that I am having is this, i am trying to search through a list of 5 possible items using a IF ELSEIF statement. The IF statment i have worked out and seems sound to me but I need to find a character that will look for "ANY" data that is in the list. Something similar to the "*" when doing a file search in windows. So the code would look something like this: If lst1.List(4) = "*" Then With rstRecordset .AddNew .Fields(4) = lst1.List(4) .Fields(3) = lst1.List(3) .Fields(2) = lst1.List(2) .Fields(1) = lst1.List(1) End With Else If lst1.List(3) = "*" Then With rstRecordset .AddNew .Fields(3) = lst1.List(3) .Fields(2) = lst1.List(2) .Fields(1) = lst1.List(1) End With Its kind of a backwards filter (its the only way I could think to do it). Any help or advise would be greatly apriciated and pplz 4give the Noobness :-) Thanks!!!
ernow
ernow
Why not like this (Pseudo code):
dim i as integer
i = 1
do
.Fields(i) = list(i)
i = i + 1
until .Fields(i-1) = "*"

Cheers

Hesterumpe
Hesterumpe
Assuming that lst1.List(x) returnes a string and that you don't care what it is (your * wildcard), then you could do:

if lst1.List(4).Length > 0 then
' stuff
else if lst1.List(3).Length > 0 then
else ' and so on...

[EDIT]
Or combine it with ernow's suggestion:

dim i as integer
i = 1
do
.Fields(i) = list(i)
i = i + 1
until .Fields(i-1).Length = 0
Rockjs
Rockjs
TY!!!! I was able to get it working with a variation of both your suggestions. It had not accured to me to try a loop. Thanks again!! :-)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.