473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

is there a better code for removing the first character??

n8kindt
221 100+
this is what i have:

Expand|Select|Wrap|Line Numbers
  1. Right$([Var],(Len([Var])-1))
it works but i'm just curious... is there a built-in function that is better than this?
Apr 5 '08 #1
7 1423
Stewart Ross
2,545 Expert Mod 2GB
No, there is no built-in which removes just the first character.

Right$, Left$ and Mid$ are generalised to be able to remove 1, 2 ... N characters as needed, and like all built-ins are intended to have wide applicability, which would not be the case for a function removing just one character.

Whatever 'better' might mean in the context of string functions such as these, your Right$ version is fine as it is.

-Stewart
Apr 5 '08 #2
ADezii
8,834 Expert 8TB
this is what i have:

Expand|Select|Wrap|Line Numbers
  1. Right$([Var],(Len([Var])-1))
it works but i'm just curious... is there a built-in function that is better than this?
How about shorter?
Expand|Select|Wrap|Line Numbers
  1. Mid$([Var], 2)
Apr 5 '08 #3
n8kindt
221 100+
How about shorter?
Expand|Select|Wrap|Line Numbers
  1. Mid$([Var], 2)
perfect! yes that will definitely work. thank you, ADezii. i found that using this code in an unbound textbox with this code refreshes nearly instantaneously while my code took about 1 second to update. i didn't think it would make that much difference but it certainly did!

cheers,
nate
Apr 5 '08 #4
ADezii
8,834 Expert 8TB
perfect! yes that will definitely work. thank you, ADezii. i found that using this code in an unbound textbox with this code refreshes nearly instantaneously while my code took about 1 second to update. i didn't think it would make that much difference but it certainly did!

cheers,
nate
You are using 1 Function (Mid$) as opposed to 2 (Right$, Len) but I honestly thought the difference would be insignificant, that's why I didn't even mention it.
Apr 5 '08 #5
NeoPa
32,556 Expert Mod 16PB
Likewise I didn't consider the performance advantage when I looked to find ADezii had got there before me ;)

I would guess that Mid() would be quicker as it doesn't have to process the whole string before it starts to extract the required part as Right() does.

At least that's what I was going to say before considering that VBA stores strings with a preceeding length element as opposed to the way C does it with a trailing NullChar. This would rather indicate that either method should be instantaneous.
Apr 6 '08 #6
n8kindt
221 100+
At least that's what I was going to say before considering that VBA stores strings with a preceeding length element as opposed to the way C does it with a trailing NullChar. This would rather indicate that either method should be instantaneous.
you're right, Neo. i just realized i was placing Nz() around the variable in my function which slowed it down. once i did the same with the new function, it calculated at the same speed. i prefer the new one however since it is less work to sort thru in order to debug, replace variables, etc..
Apr 8 '08 #7
NeoPa
32,556 Expert Mod 16PB
Oh me too, certainly Nate :)
Apr 8 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
5
by: Isa Janfada | last post by:
Hello, I have a html text string like this: " When  creating  a  new  message,  Reset  occurs  when  '\'  is  entered  in ...
11
by: cmay | last post by:
I am having this problem... Lets say that your source XML is formatted like this: <somenode> Here is some text Here is some more text </somenode> When to a <xsl:value-of select="somenode" /I...
23
by: JoeC | last post by:
I am a self taught programmer and I have figured out most syntax but desigining my programs is a challenge. I realize that there are many ways to design a program but what are some good rules to...
16
by: junky_fellow | last post by:
Is there any efficcient way of removing the newline character from the buffer read by fgets() ? Is there any library function that is similar to fgets() but also tells how many bytes it read...
19
by: Ornette | last post by:
Hello, I'm trying to convert strings to upper without the accents. For the moment, ToUpper converts é to E with an accent... I tried to set up english culture (en) but it's the same... Any...
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
4
by: Jack | last post by:
I am fairly new to c++. I am trying to write a function that removes all occurrences of one string from another without using any C library functions. So here is the function prototype: void...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.