Focus issue

  • Thread starter Jim Flechsenhaar
  • Start date
J

Jim Flechsenhaar

I am tryign to pull the IP address from a Database field, take the first
3 octets and contenate them with ".255" My suppervisor wants this
achived this by setting focus to the 3rd "." and trimming right of it. I
am fairly new to VB programming however, being a network specilist prior
and cant find the command to set focus at the "."

Any guideance would be greatly apprecited.
 
J

Jack Jackson

I am tryign to pull the IP address from a Database field, take the first
3 octets and contenate them with ".255" My suppervisor wants this
achived this by setting focus to the 3rd "." and trimming right of it. I
am fairly new to VB programming however, being a network specilist prior
and cant find the command to set focus at the "."

Any guideance would be greatly apprecited.

I'm not sure what you mean by "setting focus". Normally setting
focus means setting input focus on a visual form.

If you have the text IP address in a variable:

Dim ip As String = "1.21.35.44"
Dim indx As Integer = ip.LastIndexOf(".")

If indx >= 0 Then
ip = ip.Substring(0, indx + 1) + "255"
End If
 
M

Mark S. Milley

Hi Jim -

You didn't specify if which version of vb you were using.

VB6
dim ipaddr as string = "1.2.3.4"
ipaddr=left(ipaddr,instrrev(ipaddr,".")) & ".255"
MsgBox(ipaddr) 'Displays 1.2.3.255

VB.NET
Dim ipaddr As String = "1.2.3.4"
ipaddr = ipaddr.Substring(0, ipaddr.LastIndexOf(".")) & ".255"
MsgBox(ipaddr) 'Displays 1.2.3.255

Happy Coding,

-Mark
 
M

Mark S. Milley

Yeah, but he seemed a bit new to programming in general.

For all I know he may have been looking for an answer in VBA.

Cheers,

-M
 
R

rowe_newsgroups

For all I know he may have been looking for an answer in VBA.

You miss the point, if a post is in a .NET group, responses should be
about .NET. As when people down the line come to search for .NET
answers, they will find only appropriate code samples.

In other words, if a new programmer, which we often see here, asks a
question and mentions no specific programming language, it shouldn't
be assumed that he/she should get C#, VB, Java, or Boo answers, a
simple VB.NET answer will suffice.

Anyways, not trying to police the board or say your answer wasn't
appreciated, just saying that wasn't necessary to give a classic VB
and VB.NET example.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
M

Mark S. Milley

Hi Seth -

I'm sure you've worked tech support before--it's not safe to assume that the
user even has the computer plugged in. I always approach helping others with
that mindset. With all respect to Jim, this question was a pretty basic one.
Given that this question came from an apparent novice, and we have no
pre-existing knowledge of what Jim's level of expertise is, it's completely
illogical to assume that he was using VB.NET, when he could just as well
have been using VBA, VB6, or VBS. Of course I completely understand that
this is a VB.NET forum, yet neither of us should assume that Jim knew that,
or that he even knew that there IS a difference between the versions of VB.
His original post offered no hints or code snippets which would have
indicated any one version over the another. It may have been is first week
of programming ever and/or his first newsgroup post ever. Even experienced
people often post on the wrong newsgroup.

I don't understand how my giving an example in both flavors of VB, just in
case, has ruffled your feathers enough that you felt it necessary to
publically point out what you feel is my mistake. Everyone here is either
seeking help, or voluntarily offering help; and, honestly, I could care less
if the advise I offered this gentleman did not fit your apparently strict
notions of what good help should look like. You may be an "MVP", but the
fact that you have given more of your time to help others on here than I
have doesn't equate to a mandate to correct other people's posts. Honestly,
all you're doing in post like your last one is discouraging me and other
good-hearted, intelligent people from volunteering their time and expertise
to try help others.

Again, all I did was provide additional information which, even if it does
not help this gentleman, may help someone else in the future who stumbles
upon it. If your having to skim over these additional few lines of code
bothered you that much then, with all due respect sir, you really need to
get over yourself.

Good Day,

-Mark
 
M

Mike Williams

You miss the point, if a post is in a .NET group, responses
should be about .NET. As when people down the line come
to search for .NET answers, they will find only appropriate
code samples.

I wish you'd tell Bill McCarthy that because he's been infesting the VB6
group for months deliberately posting .Net answers on the Classic VB (VB6
and below) group and he's been doing it deliberately to annoy people!

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top