473,412 Members | 5,385 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,412 software developers and data experts.

VB.NET: Do clause

4
How do I write Do...Loop clause until strLetter is "Y" or "y"? I know how to do it with numbers but not alphabet.
Oct 9 '08 #1
5 1284
It should be like

int x

x = "A"

while chr(x) <= "Y"
do whatever you like here
x = x + 1
loop
Oct 9 '08 #2
desi2p
4
Sorry, I should have said in VB.net.

thanks
Oct 10 '08 #3
debasisdas
8,127 Expert 4TB
try to use ASCII value of the character for the looping.
Oct 10 '08 #4
Hi there.

I hope the code below help you. Don't be scarred. Every line that begins with a character ' is just a coments. ;-)


[code]

Dim sLetter As String
'put the letter A into sLetter
sLetter = "A"
'Until sLetter is not equal Y stay into the loop
Do While sLetter <> "Y"
'Show a messagebox with the currenty letter into sLetter
MessageBox.Show(sLetter)
'You must read this function this way.
'First transform the contents of sLetter into a number (example A = 65)
'Seconde add 1 to the result ( example 65 + 1 = 66 )
'Third transform the current number (66) into a character again (66 = B )
'Last put the new character into the variable sLetter
sLetter = Chr(Asc(sLetter) + 1)

/[code]
Oct 10 '08 #5
jg007
283 100+
It should be like

int x

x = "A"

while chr(x) <= "Y"
do whatever you like here
x = x + 1
loop
I have stuck this onto a form with a button and label but you could implement the same in a 'do ... loop ' although it might be awkward when you change from lowercase to uppercase as you will need extra code to by pass the non alphabetic characters

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class Form1
  3.  
  4.     Dim letr As Char
  5.  
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.  
  8.         letr = "A"
  9.         Label1.Text = letr
  10.  
  11.     End Sub
  12.  
  13.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  14.  
  15.         letr = Chr((Asc(letr)) + 1)     ' this is increasing the character by 1
  16.         If letr = "Z" Then
  17.             Label1.Text = "Finished"
  18.         Else : Label1.Text = letr
  19.  
  20.         End If
  21.  
  22.     End Sub
  23. End Class
  24.  
  25.  
** sorry just realised that this is pretty much the same as the code above but couldn't work out how to delete! <:) **
Oct 11 '08 #6

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

Similar topics

5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
2
by: aj70000 | last post by:
This is my query select ano,max(date),a_subject from MY_TAB where table_name='xyz' and ano=877 group by a_subject,ano order by a_subject ANO max(Date) A_Subject 877 2005-01-20...
0
by: Daniel | last post by:
Is this a bug in .net file io? is there a work around? when writing a large file with using(StreamWriter ... if the network drive of the share is removed then the file is never closed. I tried...
1
by: Blake | last post by:
I created a web application in VB.net 2003 pro. The program works fine on my machine, but when I try to put it on the server, i have to take out the handles clause and I can't get half of the code...
0
by: Al Fatykhov | last post by:
Using MABLE logic engine with existing .NET applications. MABLE web services provide an interface to MABLE business objects and logic. Let us review some technical details of the MABLE web...
1
by: Larry Dooley | last post by:
Here's my issue. We've decided to replace a very critical (without it the business would lose lots of money) departmental reporting system with a built from scratch system based on .NET. The key...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
15
by: wizofaus | last post by:
I have a chunk of code which is essentially IDbCommand cmd = db.CreateCommand(); cmd.CommandText = "SELECT X, Y, Count(*) FROM Foo WHERE Z = 1 GROUP BY X, Y"; using (IDataReader reader =...
2
by: Jim.Mueksch | last post by:
I am having a problem with using calculated values in a WHERE clause. My query is below. DB2 gives me this error message: Error: SQL0206N "APPRAISAL_LESS_PRICE" is not valid in the context where...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.