Home » VB.Net

Underline text in variable.

Making a WPF app...

I have text going to a textbox.

txtOutPut.AppendText("blah blah " & variA & " blah blah " & variB & " blah blah")

Is it possible to underline/bold/italic the output of "variA" and "variB" with out effecting the rest of the text?

If I need to switch to a another control to perform this, please let me know and how to format the variables. Thank you.



2 Answers Found


Answer 1

I would post your question to the WPF forum, or perhaps a moderator can move the question there:




Answer 2


It is not so important if it is WPF or WFP both hold the RichTextBox which is typical for rich text variations in the contents.




Following is the code I am using

ControlTemplate x:Key="MenuButton" TargetType="Button" >
                        <TextBlock Text="{TemplateBinding Content}" Width="150" TextAlignment="Center" Height="23" 
                                   HorizontalAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Top" 
                                   Foreground="#FFF8F8F8" FontSize="12" TextDecorations="Underline"></TextBlock>

I want to increase the line width of the underline that is created by the textdecoration.  

Looking forward to hear.


I'm making like a tally counter and my only error says that it cant convert my variable to a string. Can someone tell me how I can fix that? Here's my code:



private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)




int One = Answer1->Text;



if (YesOne->Checked)










I have a formula this is working:

=IF(ISERROR(MID(J4,FIND("6/23/2010",J4),LEN(J4)-FIND("6/23/2010",J4))),"No Comments for Today",MID(J4,FIND("6/23/2010",J4),LEN(J4)-FIND("6/23/2010",J4)))

This extracts from a string where there the DATE is.

However I would prefer to NOT change the formula each day so ideal I want to put 6/23/2010 into a cell, then simply change the cell and recalc my 'extract'.

For example if I put 6/23/2010 into B1, I would like to use the following formula

=IF(ISERROR(MID(J3,FIND(B1,J3),LEN(J3)-FIND(B1,J3))),"No Comments for Today",MID(J3,FIND(B1,J3),LEN(J3)-FIND(B1,J3)))

However I am struggling with B1 becoming a DATE when I enter it, then if I change it to text I get a numerical value.

Basically how can I use a date variable in a formula.

thanks in advance


I am using Small Basic and am reading from a data file a line at a time into a string or text variable.  That's the only way I have found to read the data.  Now I have a string such as "11,23,9,42,37,43"  and I need to seperate this into numeric values.  I don't know how to do this.  Can anyone help me?

I am 67 years old and many years ago i wrote programs in Quick Basic.  This was easy to do in that language using a Val(textdata) function but not in Small basic.  If you can help me I would very much appreciate it!


I want something like this:



Public Program()
string vari = "echo hello >> hello.txt"if (vari [has '>>'in it]
make hello a string and hello.txt a string;
write the stringfor hello to a file called hello.txt using its string;




I'm somewhat new to Vbasic, I got it as an upgrade from Python, and I'm loving it so far.  


What I'm trying to do is create an application that will:

-Allow a user to input a path for a program.

-Store the path as a registry key.

-Read the registry key.

-Launch the program.


I have come up with a rather bad method.  Currently the user must manually type out the path, and this isn't very good, because in the future, I'd like to have multiple programs running from a the same folder, while only having the user select the folder once.

I decided that a "Browse" window that allowed them to set the folder path would be best.  So my questions are:


Once they choose the folder path, I have it defined as a variable.  Then to launch, I have System.Diagnostics.Process.Start(path)  Path is a string, the registry key.  I have that part working, but I'm wondering if I could do something like System.Diagnostics.Process.Start(path,"\my_program.exe")

This way, the string "path" being merely the folder path, and the executables being run from inside the folder.  

I also am working on a browse window.  I found this code on the internet:


Dim theFolderBrowser AsNew FolderBrowserDialog

    With theFolderBrowser
      .RootFolder = Environment.SpecialFolder.Desktop
      .SelectedPath = "C:\Program Files"
      .Description = "Select the source directory"If .ShowDialog = DialogResult.OK Then

Now that code will allow me to let the user choose a folder.  Is there a way to set the chosen folder path as a variable?  I can't quite figure that out.  


Many thanks!  I usually would reference my books, but none of the ones I have cover any of this.  


We attempted to implement the Chapter 2 Framework from the Knight, Vermeen, Moss, Hackney book on SSIS 2008: Problem Design Solution. We see a couple of problem areas (at least) in our interpretation of the guidelines from the book.

1. We are attempting to have one connection string per server: dev/prod

2. We have set up environmental variables per server: dev/prod

3. We have set up XML Package Variables per server: dev/prod

4. We have set up System Variables per server in SQL Server: dev/prod

Problem 1:

We've had to manually key in the common connection string to all packages on a server environment in the component properties area (control flow; not data flow--ok there)

Shouldn't the connection property find the connection that we've instantiated and provide us with a pull down to select it?

The components are un-editable after we select the common connection string, but they still run properly in our SQL Server Agent Job.

Problem 2:

The dev server variable overlays the prod server variable information duringprod component editing

We are'nt sure if these problems are related.

Here is our package variable:



Here is our DTSconfig file; we have a few variations of this that we've tried.

<?xml version="1.0"?>
   GeneratedBy="MEDC\SSIS Team"
   GeneratedDate="9/20/2010 04:00:00 PM"/>
  <ConfiguredValue>Data Source=MEDC-SSIS\SSISSQL2008;User ID=sa;Initial Catalog=MedcDwProd;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;</ConfiguredValue>

I've validated the SSIS_Configurations table for data similarities in both dev and prod.

dev has:

CommonConfigurations Data Source=MEDC-SCCM-SQL\SCCMSQL2008;User ID=sa;Initial Catalog=MedcDwDev;Provider=SQLNCLI10.1;Integrated Security=SSPI; \Package.Variables[User::connMedcDwDev].Properties[Value] String

Prod has 2, since I've been experimenting with the SSIS_MEDC piece.

CommonConfigurations SSIS_MEDC \Package.Connections[SSIS_MEDC].Properties[Name] String    ***(Experimental)

CommonConfigurations Data Source=MEDC-SSIS\SSISSQL2008;User ID=sa;Initial Catalog=MedcDwProd;Provider=SQLNCLI10.1;Integrated Security=SSPI; \Package.Variables[User::connMedcDwProd].Properties[Value] String

Our goal is to make one change per server for the connection strings.

Some of this work was manually performed.

Anyone want to take a critical look at our framework?

Many Regardx,










Please help I am having troubles making the code run. I have a web page with a gridview and a checkbox. I would like the button when selected to pass the category id. I have managed to get it work without paging. Once the paging kicks in see below, I am unable to run the code. Please see below.






In the design: ASPX


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            BorderStyle="Solid"    CellPadding="4" DataKeyNames="Categoryid"
            BorderColor="Silver" BorderWidth="1px"    Width="300px"
            DataSourceID="SqlDataSource1" AllowPaging="True" PageSize="3" OnPageIndexChanging="GridView1_PageIndexChanging">   
            <asp:BoundField DataField="Categoryid" HeaderText="Categoryid"
                InsertVisible="False" ReadOnly="True" SortExpression="Categoryid" />
            <asp:BoundField DataField="Category" HeaderText="Category"
                SortExpression="Category" />

                <asp:TemplateField HeaderText="Categories" HeaderStyle-HorizontalAlign="Left">       
                       <asp:CheckBox ID="chk1" runat="server"
                        Text='1' />

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>


      <asp:TemplateField HeaderText="Hidden" HeaderStyle-HorizontalAlign="Left">       
                   <asp:HiddenField ID="hiddenCatIDs" runat="server" />

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>


        </Columns>    <HeaderStyle HorizontalAlign="Left" BackColor="#f0f0f0" />
        <PagerSettings PageButtonCount="3" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT [Categoryid], [Category] FROM [Category]">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

In the ASPX.VB

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim chk As CheckBox

        TextBox1.Text = String.Empty

        For Each rowItem As GridViewRow In GridView1.Rows
            chk = CType(rowItem.Cells(0).FindControl("chk1"), CheckBox)
            If chk.Checked Then
                TextBox1.Text &= GridView1.DataKeys(rowItem.RowIndex)("Categoryid").ToString() & ","
            End If

    End Sub

    Public Sub SelectedCheckBoxes()
        Dim hiddenIDs() As String = {}
        If Not String.IsNullOrEmpty(hiddenCatIDs.Value) Then
            hiddenIDs = hiddenCatIDs.Value.Split(New Char() {"|"})
        End If
        Dim arrIDs As New ArrayList()
        Dim CatID As String = "0"
        If hiddenIDs.Length <> 0 Then
        End If

        For Each rowItem As GridViewRow In GridView1.Rows
            Dim chk As CheckBox

            chk = CType(rowItem.Cells(0).FindControl("chk1"), CheckBox)
            CatID = GridView1.DataKeys(rowItem.RowIndex)("CategoryID").ToString()
            If chk.Checked Then
                If Not arrIDs.Contains(CatID) Then
                End If
                If (arrIDs.Contains(CatID)) Then
                End If
            End If

        hiddenIDs = CType(arrIDs.ToArray(Type.GetType("System.String")), String())

        hiddenCatIDs.Value = String.Join("|", hiddenIDs)
    End Sub

    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
        GridView1.PageIndex = e.NewPageIndex
    End Sub

End Class







Hi, i have a variable


that loops through a results set

Now, i want to replace text contained in vLoop before submitting it to the Execute SQL Task (SqlSource: this variable vLoop)

How can i do that?

I don't know how to use EvaluateExpression for this variable for this particular scenario

The vLoop changes value for every loop iteration, and i have to replace some text in it everytime before SQL Task executes it


-srinivas yelamanchili




So I'm just beginning to learn C++ using VS10 express, I just upgraded to VS10Pro (free software for students is awesome!). I've been writing console apps and everything is going fine. I decided to try to make one of my console apps into a windows app. It's pretty simple, it takes a few integers from the user, performs a few calculations on them, then gives a few integers as output. I have successfuly written it as a console app, now I want to try and mae a windows version.

So I've created a form that has a few text boxes for the user to input information, a few text boxes where I want the results displayed, and a button that I would like to use to begin the calculation once it is clicked. I have no idea how to get the user input from the text boxes and get it into the appropriate variables.

I have a class called Property, it stores the name a property, the monthly income from the property, how many units of the proerty are owned, and has the appropriate functions to access and modify member variables. Suppose I have an instance of a Property called House, and the number of units owned is stored in a variable House.itsUnitsOwned. Now I have a from with a textbox called HouseUnitsOwned and I want to get the value in this textbox into the variable House.itsUnitsOwned. In the console version I would get an int from the user, say unitsOwned then assign the value of unitsOwned to House.itsUnitsOwned by House.setUnitsOwned(unitsOwned).

The class is defined in property.h, VC++ created Form1.h for me and I've given it the appearance I want but no functionality, and the main code is in propertyIncome.cpp.

I have looked and cannot find up to date information on how to do this in VC++10 on the web. I figured by trying to write simple windows apps it would help me learn both C++ and windows programming at the same time, and they don't get much simpler than this. Any help would be greatly appreciated.




Hi All.

I have variables in package  (most of them are result of row count).
I need to write them in txt file (to see resume of package work).
I also have connection to txt file (type: create file)
Its connectionstring is dynamic and depends on variable (through Expressions connectionstring)
I want VB - because all examples I have now done in VB

I understand that I should use Dts.Variables
smth like :
Dts.Variables(“vsExtractionSQL”).Value =  “SELECT * FROM Purchasing.PurchaseOrderDetail WHERE ModifiedDate > ‘” + Dts.Variables(“vdtLastModifiedDatetime”).Value.ToString + “’”

Problem : How can I write it to text file  -
(smth like fopen, fclose ,fputs )
I have not much experience in dot net
Could somebody provide basic VB script for working with file
or provide reference to it.


I'm working on a web part that should list all site collection administrators based on a given site collection in a SPGridView.
Apart from listing all users that are a site collection administrator (through SPUserCollection SPWeb.SiteAdministrators), I also want to mark the primary and secondary owners. They should be marked with an image (one image for primary owner, a second for secondary owner).
This all works, but for some reason I can't put an "alt" tag behind these images:

private void BindData()
          using (SPSite site = new SPSite(url.Text))
            using (SPWeb web = site.OpenWeb())
              Label title = new Label();
              title.Text = web.Title;
              title.Style.Add(HtmlTextWriterStyle.Color, "#9d0e2d");
              title.Style.Add(HtmlTextWriterStyle.FontSize, "18px");
              title.Style.Add(HtmlTextWriterStyle.MarginLeft, "-1px");

              DataTable source = new DataTable();

              SPGridView grid = new SPGridView();
              grid.AutoGenerateColumns = false;
              grid.Style.Add(HtmlTextWriterStyle.MarginTop, "6px");

              ImageField owner = new ImageField();
              owner.DataImageUrlField = "Owner";
              owner.HeaderText = "Owner";

              BoundField name = new BoundField();
              name.HtmlEncode = false;
              name.HeaderText = "Name";
              name.DataField = "Name";

              BoundField account = new BoundField();
              account.HeaderText = "Account";
              account.DataField = "Account";

              BoundField email = new BoundField();
              email.HtmlEncode = false;
              email.HeaderText = "E-Mail";
              email.DataField = "Email";


              source.Columns.Add(new DataColumn("Owner"));
              source.Columns.Add(new DataColumn("Name"));
              source.Columns.Add(new DataColumn("Account"));
              source.Columns.Add(new DataColumn("Email"));

              SPUserCollection users = web.SiteAdministrators;
              foreach (SPUser user in users)
                SPFieldUserValue value = new SPFieldUserValue(web, user.ID, user.LoginName);
                int id = value.LookupId;

                if (user.IsSiteAdmin)
                  DataRow row = source.NewRow();
                  if (user.LoginName == site.Owner.ToString())
                    row["Owner"] = "/_layouts/images/bla/ico_pri_owner.gif";
                    owner.AlternateText = "Primary site collection administrator";
                  else if (user.LoginName == site.SecondaryContact.ToString())
                    row["Owner"] = "/_layouts/images/bla/ico_sec_owner.gif";
                    owner.AlternateText = "Secondary site collection administrator";
                    row["Owner"] = null;
                  row["Name"] = "<a href=" + url.Text + "/_layouts/userdisp.aspx?ID=" + id + ">" + user.Name + "</a>";
                  row["Account"] = user.LoginName;
                  row["Email"] = "<a href=mailto:" + user.Email + ">" + user.Email + "</a>";
              grid.DataSource = source;
      catch (Exception ex)

The part which doesn't work is the if-else clause where I want to assign an AlternateText to the ImageField.
What happens is that the "alt" text always shows "Secondary site collection administrator" regardless of what type of administrator it belongs to. I don't think there's something wrong with my if-else if-else clause (since displaying the different images works as it should), is there?

Thanks in advance!
Hi I have a many textblock t00 , t10, t20 .... In vb i have option to create 2 D array of textblock but in dot net not have what to do when i want to change text of textbolck at run time without knowing the name as tij

Hi I have a many textblock t00 , t10, t20 ....

In vb i have option to create 2 D array of textblock but in dot net not have

what to do when i want to change text of textbolck at run time without knowing the name as tij 


When I declare a variable of int or char type,the nametype is written in blue,
 while if I declare a variable of string type, the nametype is written in black
(it is not underlined by the editor). This is normal or it is a bug?

My Pc is Core2 Duo, XP home,VC++ 2010 Express.



Continuing trying to rewrite my old form letters and I am hung up on the underlining and printer codes.

Ideally, I would like my letters to have 8 or 10 spaces, then underlined text.  I have tried various forms, but still cannot figure out the "???" commands.  Here's where I am and I am hoping that someone can help.  My printer (HP 2200dt) uses the following codes for underlining: Esc&d0Dd.  Here is my little test program.   tried both with CHR() and with {}:

set device to printer prompt
set console off
**ESC = chr(27)
**&  = chr(38)
**d  = chr(100)
**0  = chr(48)
**D  =chr(68)
**d  = chr(100)
??? "          "+CHR(27)+CHR(38)+CHR(100)+CHR(48)+CHR(68)+CHR(100)  +"Is this underlined and tabbed?" +CHR(27)+CHR(38)+CHR(100)+CHR(64)
??? "        {ESC}{&}{d}{D}{0}{D}{d} Is this underlined and tabbed now?"
set print off
set printer to

I have studied the examples in http://fox.wikis.com/wc.dll?Wiki~MicrosoftRTFControl but I just cannot figure it out.



I see a setting in the Tools->Options->Fonts and Colors for Compile Error showing a blue squiggly line underlining the code, but for some reason when I compile and have errors there is nothing underlined in the source code.   Is there a way to enable this in VS2005SP1?  Thanks....

I do not want my hyperlinks (a tags) to be underlined when the user hovers over them. I have tried using the following:


but it does not seem to make any difference. I know that IE gives you the option of when to underline links, one of which is hover, but I thought CSS overrides this? Any ideas? (I am using IE8 on Windows 7) Thanks.

Nathan Sokalski


Hi, Guys:

  I am fight with this socket disconnec issue for couple days. I am using ChannelFactory.CreateChannel() to create channel and do the operation async. I don't call channel.Close(), instead, I return this channel back to my own pool for servicing next operation. If the next operation comes in 100 seconds, then the cached channel has no issue. but if this cached channel sits idle for over 100 seconds, I could (using Wireshark) see that underline socket get closed, which wasn't caused by server side. This behavior happened to both basicHttpbinding and WsHttpbinding, and there is no cue from configuration file. I know how to change the idle time out in configuration file for netTcpBinding: to change receiveTimeout value.

My code has the logic to restart a new channel to serve the operation when the cached channel was faulted. It will be nice to set the idle time out to 10 minutes.

After I read this article:

http://msdn.microsoft.com/en-us/library/ms731078.aspx, I am suspeciou that it can't be set up inside WCF application, more like TCP/IP setting. It seemed that some layer code (lower than WCF) closed the socket. The worse was that the close-event-handler related to the cached channel didn't fired at all.

This article, http://support.microsoft.com/Default.aspx?id=314053,  prompted me go to Windows Registry, hoping to find some paremeter related to idle time out. but I couldn't any hits there.

I even used reflector and dumped WCF library to folders and serach through it for magic "100", still got no where.

I appreciate any help or comment.


   if (textElement != null)
               btnBold.IsChecked = textElement.FontWeight == FontWeights.Bold;
               btnItalic.IsChecked = textElement.FontStyle == FontStyles.Italic;
               btnUnderline.IsChecked =   textElement. == TextDecorations.Underline[0];

How can I compare the textElement.?? to a Underline property? Both objects are different types.

<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure