Hi all,
I am trying to dynamically fill an array with any unique values from a field
(objRS.Fields(5 )) in my database with the following code below. However it
errors with "The array is fixed or temporarily blocked" for the line "REDIM
PRESERVE UserArray(Array count+1)". I can't seem to get around this. Any
suggestions? Many thanks.
Dim p
Dim UserArray(0) ' Max number of users
Dim Arraycount
Dim flag
objRS.MoveFirst
Do While Not objRS.EOF
p = 0
flag = false
'--Check if username is already in the array
Arraycount = UBound(UserArra y)
do while (p <= Arraycount) And (flag = false)
if objRS.Fields(5) = UserArray(p) then flag = true
P=P+1
loop
if (flag = false) then ' name not in array
UserArray(Array count) = objRS.Fields(5)
REDIM PRESERVE UserArray(Array count+1)
End if
objRS.MoveNext
Loop 2 2842
Try Dim UserArray() instead of Dim UserArray(0)
Dymamic arrays are dimmed just as () as the ubound.
But, why not just just select distinct or something when you create your
recordset? And if not, why use that flag thing? You can just do:
Do While Not objRS.EOF
If objRS.Fields.It em(5).Value = UserArray Then
Redim Preserve UserArray(Array Count+1)
UserArray(UBoun d(UserArray)) = objRS.Fields.It em(5).Value
Exit Do
End If
p = p + 1
objRS.MoveNext
Loop
Ray at home
"Jon" <Jo*@nospam.com > wrote in message
news:64Bmc.408$ VR4.390@newsfe1-win... Hi all,
I am trying to dynamically fill an array with any unique values from a
field (objRS.Fields(5 )) in my database with the following code below. However
it errors with "The array is fixed or temporarily blocked" for the line
"REDIM PRESERVE UserArray(Array count+1)". I can't seem to get around this. Any suggestions? Many thanks.
Dim p Dim UserArray(0) ' Max number of users Dim Arraycount Dim flag objRS.MoveFirst Do While Not objRS.EOF p = 0 flag = false '--Check if username is already in the array Arraycount = UBound(UserArra y) do while (p <= Arraycount) And (flag = false) if objRS.Fields(5) = UserArray(p) then flag = true P=P+1 loop if (flag = false) then ' name not in array UserArray(Array count) = objRS.Fields(5) REDIM PRESERVE UserArray(Array count+1) End if objRS.MoveNext Loop
Thanks...all sorted now.
"Ray at <%=sLocation% > [MVP]" <myfirstname at lane34 dot com> wrote in
message news:%2******** **********@tk2m sftngp13.phx.gb l... Try Dim UserArray() instead of Dim UserArray(0)
Dymamic arrays are dimmed just as () as the ubound.
But, why not just just select distinct or something when you create your recordset? And if not, why use that flag thing? You can just do:
Do While Not objRS.EOF If objRS.Fields.It em(5).Value = UserArray Then Redim Preserve UserArray(Array Count+1) UserArray(UBoun d(UserArray)) = objRS.Fields.It em(5).Value Exit Do End If p = p + 1 objRS.MoveNext Loop
Ray at home
"Jon" <Jo*@nospam.com > wrote in message news:64Bmc.408$ VR4.390@newsfe1-win... Hi all,
I am trying to dynamically fill an array with any unique values from a field (objRS.Fields(5 )) in my database with the following code below. However it errors with "The array is fixed or temporarily blocked" for the line "REDIM PRESERVE UserArray(Array count+1)". I can't seem to get around this.
Any suggestions? Many thanks.
Dim p Dim UserArray(0) ' Max number of users Dim Arraycount Dim flag objRS.MoveFirst Do While Not objRS.EOF p = 0 flag = false '--Check if username is already in the array Arraycount = UBound(UserArra y) do while (p <= Arraycount) And (flag = false) if objRS.Fields(5) = UserArray(p) then flag = true P=P+1 loop if (flag = false) then ' name not in array UserArray(Array count) = objRS.Fields(5) REDIM PRESERVE UserArray(Array count+1) End if objRS.MoveNext Loop
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rob Ristroph |
last post by:
Hi,
It's pretty unhelpful to post "I have a huge piece of code that
crashes in strange places, what's the problem?" but that's basically
my problem and I really am at my wit's end.
The piece of code in question always crashes in an STL operation
such as a vector.push_back, but the location of the crash changes as I
change how various parts are handled in memory, i.e., make some things
dynamically allocated instead of new'd. I know...
|
by: masood.iqbal |
last post by:
I am having lots of trouble getting a simple program that initializs a
dynamically allocated 2D array to work. My 2D array is not getting
initialized properly, and additionally I am getting a "Null pointer
assignment" error. Kindly help.
Also, eventually I intend to move this logic to a separate function.
For that, I believe, that I will need to pass a
pointer-to-pointer-to-pointer type as an arguent. Please confirm.
|
by: stephenma7 |
last post by:
Hi, everybody. I am new here.
I have encountered these many problems for the last couple of days. I
have Linux Fedora Core 3(Gnu G++ 3.4.2), Linux Fedora Core 2 (Gnu G++
3.3.3), Red Hat 9 (Gnu G++ 3.2.2, this is dual processors).
I have the same set of programs that I wrote and when I ran on the
three machines, which have different amount of memories, processors'
speeds, and settings. I got three different seg faults at different...
|
by: Shawn Modersohn |
last post by:
For the script:
<script language="JavaScript">
function pullPage(){
var arrayLength=document.teamSelectionF.teamSelectionS.length;
var pageNav = new Array(arrayLength);
var
gotoNum=document.teamSelectionF.teamSelectionS.options.value;
pageNav="http://www.tandtsports.com";
pageNav="http://www.tandtsports.com/Cougars.html";
|
by: Sjaakie |
last post by:
Hi there,
I'm trying to get this working with Firefox. Can you point out what's
wrong? No problems with IE, Firefox doens't fill selMonth...
TIA
>>> the script... >>>
<select name="selDay" id="selDay" style="width:50;" ></select> -
<select name="selMonth" id="selMonth" style="width:50;"></select> -
| |
by: yogi |
last post by:
Hi guys,
I'm trying to write a program that will read in a series of files and
create a 3D array from the files read in for converting 2D images to 3D
objects. The values read in will be considered as pixel colours and the
size that 1 pixel occupies will depend on an input from the user when
running the program. How can I dynamically change the data type of my 3D
array at runtime. eg. 3D array was defined as type unsigned char in the
code...
|
by: Ray D. |
last post by:
I'm trying to write a C function to compute the compressed row storage
(CRS) vectors of a 2-d matrix. This is used primarily for increasing
computing efficiency of matrices whose main elements are zeros. So
for example, if you were given the following matrix:
A = { 0, 0, 1, 0;
0, 3, 0, 0;
6, 0, 4, 0}
the function would compute three vectors - the non-zero element
|
by: attackwarningred |
last post by:
Dear All,
Hello! I've just started to use Python and its a lovely
language! I've previously programmed in Fortran 95 and have just began
to use numpy. I'm having a few problems with arrays in Python though and
wondered if someone could offer me some advice?
I wrote the following Fortran code to randomly generate numbers from
a log-normal distribution for use in a Monte Carlo model:
do n=1,shotcount
F(n)=G05DEF(F_mean,F_sd)
|
by: stevenruiz |
last post by:
Hello All
My question mainly is how to use/reference Double Pointers? I am
currently trying to understand what the meaning of a 'vector of
pointers' means also? What I am trying to do is take a char array and
break it up into words omitting the spaces. What needs to be noted is
that I am trying to accomplish this only using char ** and char *.
Therefore, I am creating it from scratch. Below is code that I have
written so far:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |