 |

|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
Hello All
I am trying to implement MVVM and use IDataErrorInfo interface to validate data in the model classes
I base model class implementing IDataErrorInfo interface
public class BaseClass: IDataErrorInfo
{
<Properties and Members of BaseClass>
#region IDataErrorInfo
public string Error
{
get { return String.Empty; }
}
public string this[string PropertyName]
{
get { return this.GetValidationError(PropertyName); }
}
#endregion
}
Now I want drive a class from Base class
public class DrivedClass: BaseClass
{
}
How do I use IDataErrorInfo members in the derived class to carryout validation of the properties in the derived class??
|
|
|
|

|
Okay, declaring arrays is fairly simple… Just like declaring any other variable with the exception of the square brackets.
Initializing one-dimensional arrays also seems fairly simple enough… Initializing two-dimensional arrays is a bit more complicated but still semi-sort of simple if you pay attention to what you're doing.
Jagged arrays, like two-dimensional arrays… Can be a little tricky if you're not paying attention.
I get and understand the declaration and initialization of the jagged arrays, and that you can change the value of any element by re-declaring your array variable…
I'll use the example from the book I'm reading:
(never mind some of the missing closing curly brackets, before I add any more code I want to understand and learn this part first)
using System;
class JaggedClass
{
static void Main ()
{
int[][] myJaggedArray = { new int[] {2, 3, 4}, new int[] {5, 6, 7, 8, 9} };
myJaggedArray[0][0] = 11; myJaggedArray[1][2] = 22;
|
|
|
|

|
how to use counting function in c# for counting values
|
|
|
|

|
how to print
*******
*****
***
throug nested loof
in c#
|
|
|
|

|
I have this assignment:
Develop a C# console application that implements three arrays; a string array initialized with exactly the following five data items { "Widget 15.50", "Thingy 50.99", "Ratchet25.00", "Clanger115.49", "Fracker75.25" }, a string array to hold the five part names to be parsed from the previously detailed string array, an array of five double value prices to be parsed from the previously mentioned array.
Create a void method that will accept as arguments the two arrays of strings and the array of doubles when called from Main. In the method you will access the five members of the first string array mentioned above and you will parse out the name portion of each string element (first 7 bytes), assigning the string value to the corresponding element in the array of names. In the method you will also parse out the numeric portion of each string and assign it to the corresponding element of the price array. The parsing should be done using the string method SubString.
In Main, after calling the parsing method you will display the elements of both the array of names and the array of prices side-by-side (do not display the array from which you parsed the data items).
The output should look something like this:
Widget $15.50
Thingy $50.99
Ratchet $25.00
Clanger $115.49
Fracker $75.25
Press any key to continue . . .
This is what I have so far and I have an error and I don't know what is wrong:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] combo = { "Widget 15.50", "Thingy 50.99", "Ratchet25.00", "Clanger115.49", "Fracker75.25" };
string name = Convert.ToChar(combo[].Substring(0, 7));
double price = Convert.ToInt32(combo[].Substring(7, 12));;
parse(ref combo, ref name, ref price);
}
static void parse(ref string[] combo, ref string name, ref double price)
{
for (int x = 0; x < combo.Length; x++)
{
Console.Write(name + price + "\n");
}
}
}
}
It gives me a syntax error for lines for 14 and 15.
modified yesterday.
|
|
|
|

|
Hi
I want to write a client to client chat program by c#;before i wrote client/server chat program ,how can i convert it
thank you all
|
|
|
|

|
I have this assignment with arrays and I'm totally lost. I'm ready to drop out of the class because it is too hard for me. I just want to finish the class and not fail.
Develop a C# console application that implements two parallel arrays in Main, one to hold double values called item_price and the other to hold strings called item_name. Each array will hold 5 values. Use an initializer to fill the item_price array with the values 15.50, 50.99, 25.00, 115.49, 75.25. Use an initializer to fill the item_name array with the values "Widget", "Thingy", "Ratchet", "Clanger", "Fracker". This application will use a method to change the corresponding prices for items based on a price point and a multiplier which will require double value types. The inputs for the price and multiplier are input from the console.
Create two static methods, one called changePrices and one called printit. When the changePrices method is called from Main you should pass the item_price array by reference, the price point and price difference values input from the console to it. The changePrices method should loop through the item price array and check the price point to determine the increase in price for each price array element.
|
|
|
|

|
Hi Alll
Please Anybody have code or knowledge about this question please send me give solution.
thanking you for supporting me.
Pankaj Tak
|
|
|
|

|
how to check arithmetic ,logical, trigonometric and gromatric
values in nested switching ..
i mean how to use nested switch for the above operators
when i press l it us some logical operation \
and when i press a give some arithmetic operation and so on....
|
|
|
|

|
i many time call method with the help of thread like
static void Main( string[] args )
{
Thread t = new Thread( MyFunction );
t.Start();
}
static void MyFunction()
{
//code goes here
}
and some time i use ThreadPool class also like
System.Threading.ThreadPool.QueueUserWorkItem(delegate {
MyFunction();
}, null);
but i do not understand what is the difference between calling any method with the help of thread class or ThreadPool class
so i am looking a good discussion about what is the difference between Thread & ThreadPool class.also need to know when we should use Thread class to call a method and when ThreadPool class to call any method ? if possible discuss also with sample code with sample situation.
another very important question is that if i start multiple thread then my application performance will become low or bad ? if yes then tell me why...?
now also tell me what is BackgroundWorker class and how it is different from Thread & ThreadPool class. how far i heard that BackgroundWorker class also create a separate thread to run any method. so please discuss how it is different from Thread & ThreadPool class and when one should go for BackgroundWorker class.
here is small sample code of BackgroundWorker
private void button1_Click(object sender, EventArgs e)
{
BackgroundWorker bw = new BackgroundWorker();
// this allows our worker to report progress during work
bw.WorkerReportsProgress = true;
// what to do in the background thread
bw.DoWork += new DoWorkEventHandler(
delegate(object o, DoWorkEventArgs args)
{
BackgroundWorker b = o as BackgroundWorker;
// do some simple processing for 10 seconds
for (int i = 1; i <= 10; i++)
{
// report the progress in percent
b.ReportProgress(i * 10);
Thread.Sleep(1000);
}
});
// what to do when progress changed (update the progress bar for example)
bw.ProgressChanged += new ProgressChangedEventHandler(
delegate(object o, ProgressChangedEventArgs args)
{
label1.Text = string.Format("{0}% Completed", args.ProgressPercentage);
});
// what to do when worker completes its task (notify the user)
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object o, RunWorkerCompletedEventArgs args)
{
label1.Text = "Finished!";
});
bw.RunWorkerAsync();
}
tbhattacharjee
|
|
|
|

|
I've created a small VS 2012 c# project that eventually does a divide-by-zero. I catch the exception and then do a call to MiniDumpWriteDump and it successfully creates a dump file.
Obviously I have the pdb and source files.
What I'd like to do now is load the minidump into VS and then examine it so I can get familiar with how to read it etc. As I understand, the minidump file should be able to display exactly what was going on and using the debugger, I could look at the stack trace and display variables? Double-clicking the minidump file opens it in VS 2012 but I'm really left with the puzzle, what now? Has anyone loaded a dump file before and looked at it in VS?
I've searched for answers but the term minidump is so ubiquitous that it's really not easy to what's relevant to VS and what isn't. I'm led to believe that if I have the dump file and the pdb files and the source then I should be able to see an exact snapshot of went turned tits-up. I just don't really know what's the best way to load it and change any settings to use it. If I can get it working on a simple divide-by-zero app then I can use them in our production app which'll help us deal with fatal problems reported by our users.
TIA.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|

|
I have a simple question but for someone like me who is not familiar with c# is giving a bit of trouble. I am making a basic script in c# for a bot in a videogame (TERA). What I want is to avoid attacking static immortal debuffs when my character approaches to them. A simple script without nothing would be like this:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace SimpleCombat
{
public class EntryPoint : ZurasBot.Addons.ICombat
{
public override string Name
{
get
{
return "Shell";
}
}
public override void OnLoad()
{
}
public override void OnUnload()
{
}
public override void Settings()
{
}
public override void OnBotStart()
{
}
public override void OnBotStop()
{
}
public override void Patrolling()
{
}
public override Boolean Pull(MyTERA.Helpers.ObjectManager.TERAObject Object)
{
return true;
}
public override Boolean Combat(MyTERA.Helpers.ObjectManager.TERAObject Object)
{
return true;
}
public override void PostCombat()
{
}
}
}
The question is: How/where do I declare/define the pullfunction? What I have to add is this:
if (Object.S1NPCDataController.Name == "name1") return false;
"name1" being the name of the static immortal debuff. Anyone could help me? It is important to me since I am helping a friend to level up his character so he can play with the rest of us! I would really appreciate any help you could give me, it would mean a lot to me! Thank you very much for your help, I hope I can find a solution! Have a nice weekend!
|
|
|
|

|
how use nested switch in c#
|
|
|
|

|
Hello,
I am beginner ( Noob ) in c#,
I am trying to make a small Asset browsing tool for myself, I just wanted to be sure if the way i am going is good or is there a better way to do it.
Currently I have 4 classes
ThumbViewer : extends FlowlayoutPanel
ThumbItem : extends Button
CacheManager.
I have overridden the paint method in the ThumbItem class and painting my Own way.
I also have a Background worker process which reads image file and gets thumbnail out if it and then assigns it to the Image property in the Button.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.ComponentModel;
using System.Drawing.Imaging;
namespace Thumbnailer
{
public class ThumbItem : Button
{
private BackgroundWorker bw;
private string _fullfilename;
private bool _ismouseover = false;
private bool _isSelected = false;
private const int THUMBNAIL_DATA = 0x501B;
private ToolTip _btn_Tooltip;
private bool isDisposed = false;
private bool _itemvisiblecalled = false;
private bool _itemnotvisiblecalled = false;
#region Properties
public string FullName
{
get { return _fullfilename; }
set { _fullfilename = value; }
}
public bool Selected
{
get { return _isSelected; }
set { _isSelected = value; }
}
public Image FileIcon { get; private set; }
public bool isVisible { get; set; }
public string FileName { get; set; }
#endregion
#region Constructor
public ThumbItem()
{
this.Text = "PlaceHolder Thumb";
this.Size = new Size(128, 144);
this.Padding = new Padding(4);
this.BackColor = Color.Transparent;
this.Font = new Font("Verdana", 9, GraphicsUnit.Point);
this.DoubleBuffered = true;
bw = new BackgroundWorker();
bw.WorkerReportsProgress = true;
bw.WorkerSupportsCancellation = true;
bw.DoWork += new DoWorkEventHandler(BW_DoWork);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BW_RunWorkerCompleted);
}
public ThumbItem(string file)
: this()
{
if (!File.Exists(file))
{
throw new FileNotFoundException("Specified file " + file + " doesnt exists.");
}
FileInfo fi = new FileInfo(file);
this.Text = fi.Name.Replace(fi.Extension, "");
this.FileName = fi.Name.Replace(fi.Extension, "");
this.FullName = fi.FullName;
bw.RunWorkerAsync();
}
~ThumbItem()
{
if(!this.isDisposed)
{
bw.DoWork -= BW_DoWork;
bw.RunWorkerCompleted -= BW_RunWorkerCompleted;
this.bw.Dispose();
}
}
#endregion
#region Background Worker
private void BW_DoWork(object sender, DoWorkEventArgs e)
{
if (this._fullfilename != "")
{
Image _thumbimg = null;
Image _icon = null;
FileInfo fi = new FileInfo(this._fullfilename);
if(fi.Extension == ".JPG")
{
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(this._fullfilename)))
{
using (Image img = Image.FromStream(ms))
{
if (CacheManager<Image>.CurrentInstance.isExists(this.FullName))
{
_thumbimg = CacheManager<Image>.CurrentInstance.GetByKey(this.FullName);
}
else
{
if (img != null)
{
_thumbimg = img.GetThumbnailImage(64, 64, abort_callback, IntPtr.Zero);
CacheManager<Image>.CurrentInstance.Add(this.FullName, _thumbimg);
}
}
}
}
}
else
{
_icon = Icon.ExtractAssociatedIcon(this.FullName).ToBitmap();
}
e.Result = new Image[] { _thumbimg, _icon };
}
}
private void BW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Image = ((Image[])e.Result)[0];
this.FileIcon = ((Image[])e.Result)[1];
this.Invalidate();
}
#endregion
#region Painting Methods
protected override void OnPaint(PaintEventArgs pevent)
{
Graphics gfx = pevent.Graphics;
StringFormat formatter = new StringFormat();
formatter.LineAlignment = StringAlignment.Center;
formatter.Alignment = StringAlignment.Center;
Rectangle textrect = new Rectangle(0, (this.Height / 2) - (this.FontHeight / 2) - this.Padding.All, this.Width, this.Height);
Color fontcolor = Color.White;
Rectangle parentbounds = this.Parent.Bounds;
if (this.Parent != null)
{
gfx.Clear(this.Parent.BackColor);
}
if (((this.Bounds.Bottom - 10) < this.Parent.Bounds.Top) || (this.Bounds.Top - 10) > this.Parent.Bounds.Bottom)
{
if(!this._itemnotvisiblecalled)
{
ItemNotVisible();
}
}
else
{
if(!this._itemvisiblecalled)
{
ItemVisible();
}
}
if(this.FileName == "IMG_0035")
{
Console.WriteLine("TEmp");
}
if (this.Selected)
{
gfx.FillRectangle(new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(25, 255, 255, 255), Color.FromArgb(150, 255, 255, 255), LinearGradientMode.Vertical), this.ClientRectangle);
}
if (this._ismouseover)
{
gfx.FillRectangle(new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(25, 255, 255, 255), Color.FromArgb(100, 255, 255, 255), LinearGradientMode.Vertical), this.ClientRectangle);
}
Rectangle borderrect = this.ClientRectangle;
ControlPaint.DrawBorder(gfx, borderrect, Color.FromArgb(100, 255, 255, 255), ButtonBorderStyle.Solid);
if (this.Image != null)
{
Rectangle imgrect = new Rectangle(this.Padding.All, this.Padding.All, (this.Width - (this.Padding.All * 2)), (this.Width - (this.Padding.All * 2)));
gfx.DrawImage(this.Image, imgrect);
}
else if (this.FileIcon != null)
{
Rectangle iconrect = new Rectangle(((this.Width / 2) - 16), ((this.Height / 2) - 16), 32, 32);
gfx.DrawImage(this.FileIcon, iconrect);
}
string temp = this.Text;
SizeF textsize = gfx.MeasureString(temp, this.Font);
while (textsize.Width > this.Width / 1.5)
{
temp = temp.Remove(temp.Length - 1);
textsize = gfx.MeasureString(temp, this.Font);
}
temp += "....";
gfx.DrawString(temp, this.Font, new SolidBrush(fontcolor), textrect, formatter);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);
}
#endregion
#region Helper Methods
public static Image ResizeImage(Image imgToResize, Size size)
{
int sourceWidth = imgToResize.Width;
int sourceHeight = imgToResize.Height;
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;
nPercentW = ((float)size.Width / (float)sourceWidth);
nPercentH = ((float)size.Height / (float)sourceHeight);
if (nPercentH < nPercentW)
nPercent = nPercentH;
else
nPercent = nPercentW;
int destWidth = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);
Bitmap b = new Bitmap(destWidth, destHeight);
Graphics g = Graphics.FromImage((Image)b);
g.InterpolationMode = InterpolationMode.Low;
g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
g.Dispose();
return (Image)b;
}
public void RefreshThumbnail()
{
this.Image = null;
while(!this.bw.IsBusy)
{
this.bw.RunWorkerAsync();
}
}
private void ItemVisible()
{
this._itemvisiblecalled = true;
this._itemnotvisiblecalled = false;
}
private void ItemNotVisible()
{
this._itemvisiblecalled = false;
this._itemnotvisiblecalled = true;
}
private static bool HasJpegHeader(string filename)
{
using (BinaryReader br = new BinaryReader(File.Open(filename, FileMode.Open)))
{
UInt16 soi = br.ReadUInt16(); UInt16 jfif = br.ReadUInt16();
return soi == 0xd8ff && jfif == 0xe0ff;
}
}
#endregion
#region Event Handlers
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
this._ismouseover = true;
if ( _btn_Tooltip == null)
{
_btn_Tooltip = new ToolTip();
FileInfo fi = new FileInfo(this.FullName);
string tooltiptext = "";
tooltiptext += "FileName : "+fi.Name+"\n";
tooltiptext += "Path : "+fi.FullName+"\n";
tooltiptext += "Directory : " + fi.DirectoryName + "\n";
_btn_Tooltip.SetToolTip(this, tooltiptext);
}
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
this._ismouseover = false;
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
}
#endregion
#region Event Methods
#endregion
#region UnUsed Methods
private bool abort_callback()
{
return false;
}
#endregion
private void InitializeComponent()
{
this.SuspendLayout();
this.ResumeLayout(false);
}
}
}
Can anyone please tell me if this is the best way to do it, if not then can you please guide me in right direction.
Thanks
Dinesh
|
|
|
|

|
Is there a way to make a Form flashing in c#.
First idea is to use a timer changing form color. Is there a more elegant way?
Thanks for your time
|
|
|
|

|
How can I read a the value of a column datatype Timestamp in my c# code?
I know that the timestamp is not a datetime in sql server.
I just want to read this to a byte array.
My code so far:
I have tried 3 variations and none of them even compile.
var myTimestamp = (byte)dr["TimeStamp"].ToString();
var myTimestamp = dr["TimeStamp"].ToString() as byte[];
var myTimestamp = dr["TimeStamp"].ToString();
I have googled and am unable to find it.
Pendin Approval
|
|
|
|

|
Hi to all.
I have a strange behaviour in a MDI project. I created a toolstrip with buttons in MDI parent for common operations in all children forms (New, Save and Delete).
In a child form, I have a DataGridView with a CheckBoxColumn and a TextBoxColumn with a list of options to choose by user. If i check some checkbox and I press the Save button in the toolstrip, I can't save any data: all the checkbox returns false value. But if i put a button in the child form and call the same void, all work very well.
Someone can answer why?
Here the code for button in MDI parent:
private void tsbtnSave_Click(object sender, EventArgs e)
{
if (this.ActiveMdiChild is Basic.AnalyzersCylinders) ((Basic.AnalyzersCylinders)this.ActiveMdiChild).Save();
}
Here the code to read the results:
public void Save()
{
foreach (DataGridViewRow dgRow in dgvAnalyzers.Rows)
{
if (dgRow.Cells["CheckedItem"].Value != null)
{
if ((bool)dgRow.Cells["CheckedItem"].Value)
{
}
else
{
}
}
}
}
And, obviously, the code for the button in Child form call the same Save() void.
|
|
|
|

|
Hello
Is there a way to extract some values from an XML node using the XmlPathNavigator ?
I need to extrat information from a XML file. I was first trying to use an XmlTextReader but the pure sequential access seeme a bit tedious to handle
So I was trying to use the XpathDocument
I use a XPathNavigator to browse each node of my document (see code below)
But for each product I just need to extract a few information
- Brand
- Model
- ID
(there are a lot of other unneeded information)
Is it possible to do that with the XpathNavigator ?
Or do I need another approach ?
Obviously I can write my own parser but I can't believe that there is no simple way with standard classes ?
Thanks for any help !
XPathDocument xmldoc = new XPathDocument(p);
XPathNavigator nav = xmldoc.CreateNavigator();
int j = 0;
foreach (XPathNavigator product in nav.Select("liste/mobile"))
{
j++;
}
|
|
|
|

|
I'm not sure WCF is the way I should go here but I'm keen to get to learn a new technology so I thought I should investigate it at least.
We are developing a system in which we need a server-side application (with GUI, so not a Windows service) and several client side applications that communicate with this server side application. All of this happens on the internal network so I figured that TCP binding might be suitable.
The one approach would be to write some TCP/IP server routines on the server-side application and have the clients communicate with it over TCP sockets for which we'd have to implement certain messaging. What I dislike about this approach is the fact that all comms will be request-response type. In other words, the server can only send messages to the client if the client sent a message to the server.
So the possibility of full-duplex comms of WCF seems like a perfect solution. The thing I'm unsure of is whether WCF would allow for a server-side application that has a GUI and allows for user interaction.
I thought I might try getting to know WCF first by writing a small mini system, the sandwich lady notification system, consisting of a "server" side application which runs on the receptionist's computer. A number of other computers in the office then has a client application. The client application can send a message to the server application to subscribe itself to the notifications. When the sandwich lady arrives the receptionist can then open the GUI of the application on her machine and click a button which triggers the app to send a message to all the clients that has subscribed which in turn pops up a notification on the client machine.
I realise there might be better ways to achieve this particular solution but it is a reasonable analogy of what we ultimately want to achieve with out bigger system so I figure I might gain the skills I need if I can figure out how to write this little system.
My question is, could someone tell me please whether WCF is indeed the technology that should be used for this? I have only just started reading up on it but I am getting the impression that with WCF, the server side application will have to take the form of a service, not a desktop application. Could anyone give me some clarity on this please and possibly point me in the right direction for what I'm trying to achieve?
TIA
|
|
|
|

|
Hello,
I've just started to programm in C++, using Builder C++. I need to stablish comunication via internet between two computers. I've succed using the ClientSocket Component and the ClientServer but only if the computers are in a local network but not if the computers are in different networks. Here is my code for the server:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//--------------------Abrir el Servidor---------------------------------------//
void __fastcall TForm1::BAbrirClick(TObject *Sender)
{
//Configurar el número de puerto
ServerSocket1->Port=StrToInt(Npuerto->Text);
//Abrir el servidor
ServerSocket1->Open();
//Actualizar estado de los botones
BAbrir->Enabled=false;
BCerrar->Enabled=true;
//Informar de que se ha abierto el servidor
BEstado->SimpleText="Servidor Conectado!";
//Indicar el número de conexionoes activas
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
//Activar el Boton de enviar mensaje
BEnviar->Enabled = true;
}
//----------------------------------------------------------------------------//
//---------------------Cerrar el Servidor-------------------------------------//
void __fastcall TForm1::BCerrarClick(TObject *Sender)
{
//Cerrar el Servicio
ServerSocket1->Close();
//Actualizar estado de los botones
BAbrir->Enabled=true;
BCerrar->Enabled=false;
//Informar del cierre del servidor
BEstado->SimpleText="Servidor Cerrado!";
//Actualizar el campo de nº de conectados
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
//Desactivar el Boton de enviar mensaje
BEnviar->Enabled = false;
}
//----------------------------------------------------------------------------//
//---------------------Cuando se Conecte un Cliente---------------------------//
void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{
//Mostrar aviso en la barra de estado
BEstado->SimpleText="Conectado desde "+Socket->RemoteAddress;
//Actualizar el número de conectados
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
}
//----------------------------------------------------------------------------//
//---------------------Al Desconectarse un Cliente----------------------------//
void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket)
{
//Actualizar el número de conectados
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections-1);
//Informar de la desconexión
BEstado->SimpleText="Desconectado de "+Socket->RemoteAddress;
}
//----------------------------------------------------------------------------//
//---------------------Al recibir un Mensaje----------------------------------//
void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
//Espacio para recibir el mensaje
char * buffer;
int len;
AnsiString Mensaje;
int i;
// Recibir mensaje
int *tam;
tam = new int;
*tam = Socket->ReceiveLength();
len=Socket->ReceiveBuf(buffer,*tam);
buffer[len]=0;
//Estructura para mostrar el mensaje correctamente
TTime hora = TTime::CurrentTime();
AnsiString MensajeIn = Socket->RemoteAddress;
MensajeIn += " A las " + TimeToStr(hora) + " Dice" "----->";
ChatBox->Lines->Add(MensajeIn +StrPas(buffer));
BEstado->SimpleText=IntToStr(len)+"Nuevo mensaje entrante!";
// Repetir el mensaje a los demás
Mensaje = StrPas(buffer);
strcpy(buffer,Mensaje.c_str());
for(i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
ServerSocket1->Socket->Connections[i]->SendBuf(buffer,strlen(buffer));
delete[] buffer;
}
//----------------------------------------------------------------------------//
//--------------------Enviar un Mensaje---------------------------------------//
void __fastcall TForm1::BEnviarClick(TObject *Sender)
{
//Espacio para meter el mensaje
char buffer[256];
int i;
//Recoger el Mensaje del campo de entrada
AnsiString Mensaje = CampoMensaje->Text;
strcpy(buffer,Mensaje.c_str());
//Enviarlo a los conectados
for(i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
ServerSocket1->Socket->Connections[i]->SendBuf(buffer,strlen(buffer));
//Añadirlo al Chatbox
TTime hora = TTime::CurrentTime();
ChatBox->Lines->Add("Servidor a las " +TimeToStr(hora)
+ " dice----->" + Mensaje);
}
//----------------------------------------------------------------------------//
//---------------------Borrar la Memo-----------------------------------------//
void __fastcall TForm1::LimpiarClick(TObject *Sender)
{
//Borrar
ChatBox->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CampoMensajeKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 13)
TForm1::BEnviarClick(CampoMensaje);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NpuertoKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == 13)
TForm1::BAbrirClick(Npuerto);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TcpServer1Accept(TObject *Sender,
TCustomIpClient *ClientSocket)
{
//Configurar el número de puerto
TcpServer1->RemotePort = StrToInt(Npuerto->Text);
//Abrir el servidor
TcpServer1->Open();
//Actualizar estado de los botones
BAbrir->Enabled=false;
BCerrar->Enabled=true;
//Informar de que se ha abierto el servidor
BEstado->SimpleText="Servidor Conectado!";
//Indicar el número de conexionoes activas
NOnline->Text=IntToStr(ServerSocket1->Socket->ActiveConnections);
//Activar el Boton de enviar mensaje
BEnviar->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TcpServer1CreateHandle(TObject *Sender)
{
//Actualizar el número de conectados
NOnline->Text=IntToStr(TcpServer1->Active-1);
//Informar de la desconexión
BEstado->SimpleText="Desconectado de "+TcpServer1->LocalHostName();
}
//---------------------------------------------------------------------------
How can I implement comunication (a simple chat is enough) between the two computers?
|
|
|
|

|
Hello Experts,
I am working on an Excel application and I have input in the form of an HTML table string.I need to past this string in my excel work sheet.
Please let me know how can I do this?
Thanks,
Raesa
|
|
|
|

|
...
[START]
blaaa blaa blaa
T h i s
(this is an empty line)
{END]
...
another line
--------------------------------------
I have been trying to remove empty lines appearing between
[START] and {END] within a word document.
Code seems to work if I did not have a textbox at top of my document. It seems that the textbox is also cleared once such operation takes place.
wordapp = new Word.Application();
wordapp.Visible = false;
doc = wordapp.Documents.Open(wordPath);
paragraphs = doc.Paragraphs;
bool flag = false;
foreach (Word.Paragraph paragraph in paragraphs)
{
string s = paragraph.Range.Text;
string y = paragraph.Range.Text.Trim();
if (paragraph.Range.Text == "<NE>\r")
{
flag = true;
paragraph.Range.Select();
wordapp.Selection.Delete();
continue;
}
else if (paragraph.Range.Text == "</NE>\r")
{
flag = false;
paragraph.Range.Select();
wordapp.Selection.Delete();
continue;
}
else if (paragraph.Range.Text.Trim() == string.Empty )
{
if (flag)
{
paragraph.Range.Select();
wordapp.Selection.Delete();
}
continue;
}
}
doc.Save();
wordapp.Quit();
is there any other way to achieve what I do using Range in Word or dealing with a textbox in Word?
Student of life
|
|
|
|

|
Hi,
I have a Java program that signed a token using the private key and SHA1 algorithm. Now I try to verify it using the public key and SHA1. The verification fails. Is there any compatibility issue here or I am missing something? Thanks.
Best,
Jun
|
|
|
|

|
I am programming a bit counter, a method that returns a List < int > of the positions of the bits that are "on" in a UInt32. I was reviewing the code when I encountered
position--;
bit >>= 1;
To my mind these two statements need to be atomic. To achieve at least the notion of atomicity in C#, I would change the code to
position--; bit >>= 1;
I am fiercely against this in a statement body. But in this case I think it signals atomicity. Is there a better way to do this?
Gus Gustafson
|
|
|
|

|
Hi,
Can anyone advise me on how to tell if a Forms icon is set to the default Visual Studio Icon or my own icon.
The reason I ask is that on opening it up into a tabbed document view, I only want to put the form's icon on the generated page tab is it's my own icon, not the VS one. I have everything working except the check to see if it's the default VS one.
Any help most gratefully received.
Thanks.
|
|
|
|

|
Hello, please I need help.
How can I fill a datagridview with two datasource?
Yours
|
|
|
|

|
converting database schema in form of schema graph having primary and foreign key relationship and storing in cache using datastructure........?????????
|
|
|
|

|
hey guys i'm making a ladder and snake game using C# and i'm stuck at the point where i need to move my players forward .. which means that the players move correctly only in round 1 but after that they start going backwards .
for example for player one the first turn the dice showed number 4 so it moved to square 4 , in second round the dice showed number 2 the player goes back to number two and not to number 6 as it's suppose to .. so can you help me with that i would really appreciate it
this is my code so far :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ladder__snake
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//variables to hold the players locations
int blueposition = 1;
int redposition = 1;
int round = 0;
bool drawbg = false;
Point[] squares = new Point[26];
public void main()
{
//array for the squares
squares[0] = new Point(50, 450);
squares[1] = new Point(150, 450);
squares[2] = new Point(250, 450);
squares[3] = new Point(350, 450);
squares[4] = new Point(450, 450);
squares[5] = new Point(450, 350);
squares[6] = new Point(350, 350);
squares[7] = new Point(250, 350);
squares[8] = new Point(150, 350);
squares[9] = new Point(50, 350);
squares[10] = new Point(50, 250);
squares[11] = new Point(150, 250);
squares[12] = new Point(350, 250);
squares[13] = new Point(350, 250);
squares[14] = new Point(450, 250);
squares[15] = new Point(450, 150);
squares[16] = new Point(350, 150);
squares[17] = new Point(250, 150);
squares[18] = new Point(150, 150);
squares[19] = new Point(50, 150);
squares[20] = new Point(50, 50);
squares[21] = new Point(150, 50);
squares[22] = new Point(250, 50);
squares[23] = new Point(350, 50);
squares[24] = new Point(450, 50);
}
private void button1_Click(object sender, EventArgs e)
{
round++;
label3.Text = round.ToString();
//for the blue player dice
Random rnd;
int guess;
rnd = new Random();
guess = rnd.Next(1, 7);
pictureBox1.Image = Image.FromFile(guess.ToString() + ".png");
// Get the Blue player moving
switch (guess)
{
case 1:
bluePlayer.Location = new Point(50, 450);
break;
case 2:
bluePlayer.Location = new Point(150, 450);
break;
case 3:
bluePlayer.Location = new Point(250, 450);
break;
case 4:
bluePlayer.Location = new Point(250, 350);
MessageBox.Show("It's a ladder move to square 8");
break;
case 5:
bluePlayer.Location = new Point(450, 450);
break;
case 6:
bluePlayer.Location = new Point(450, 350);
break;
}
//bluePlayer.Location = squares[blueposition+guess];
//BluePlayer += guess;
//currentPosition1 += guess;
// bluePlayer.Location = squares[BluePlayer+guess];
//guess = 0;
label4.Visible = false;
label5.Visible = true;
label5.Text = "Red Player's turn";
button2.Enabled = true;
button1.Enabled = false;
pictureBox2.Image = Image.FromFile("dice.png");
//blueposition += guess;
//bluePlayer.Location = squares[guess];
}
private void button2_Click(object sender, EventArgs e)
{
//for the red player dice
Random rnd;
int guess;
rnd = new Random();
guess = rnd.Next(1, 7);
pictureBox2.Image = Image.FromFile(guess.ToString() + ".png");
//redposition += guess;
switch (guess)
{
case 1:
redPlayer.Location = new Point(50, 445);
break;
case 2:
redPlayer.Location = new Point(150, 445);
break;
case 3:
redPlayer.Location = new Point(250, 445);
break;
case 4:
redPlayer.Location = new Point(250, 350);
MessageBox.Show("It's a ladder move to square 8");
break;
case 5:
redPlayer.Location = new Point(450, 445);
break;
case 6:
redPlayer.Location = new Point(450, 345);
break;
}
label5.Visible = false;
label4.Visible = true;
label4.Text = "Blue Player's turn";
button2.Enabled = false;
button1.Enabled = true;
pictureBox1.Image = Image.FromFile("dice.png");
}
private void groupBox2_Enter(object sender, EventArgs e)
{
if (!drawbg)
{ groupBox2.Visible = true; }
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Load_1(object sender, EventArgs e)
{
pictureBox1.Image = pictureBox2.Image = Image.FromFile("dice.png");
}
}
}
|
|
|
|

|
this program I am do it but there is an error into it ,the error is in the function ...gotoxy().the massege error is "gotoxy is undeclarated"...I am do this program by Visual Stadiue 2006...
the code:
#include<iostream.h>
class base
{private:
int n,i,j,h,x[10];
float fx[10][10];
static char c;
public:
void set(int cn,int ci,int cj,int ch,int cx,float cfx,char cc)
{
cn=n;ci=i;cj=j;ch=h;cx=x[10];cfx=fx[10][10];cc=c;
}
void show()
{cout<<"\n\t\t******\t THE DIFFREEN\t******";
cout<<"\n\n";
cout<<"\n ENTER THE NUMBER OF THE VALUSE OF X:";
cin>>n;
cout<<"\n\n ENTER THE FIRST VALUE OF X1:";
cin>>x[0];
cout<<"\n ENTER THE INTERVAL:";
cin>>h;
for(i=1;i<n;i++)
x[i]=x[i-1]+h;
cout<<"\n\n\n ENTER THE VALU OF F(X):";
for(i=0;i<n;i++)
{
cout<<"\n f("<<x[i]<<")=";
cin>>fx[i][0];
}
for(i=1;i<n;i++)
for(j=1;j<n-i+1;j++)
fx[j-1][i]=fx[j][i-1]-fx[j-1][i-1];
cout<<"\n\nX\tf(x)\t";
for(i=1;i<n;i++)
cout<<c<<i<<"f(x)\t";
cout<<"\n";
for(i=0;i<n;i++)
{gotoxy(3,i*3+4);
cout<<x[i];}
for(j=0;j<n-i;j++)
if(i+j<n)
{
gotoxy((i+1)*9,((j*3)+i+4));
cout<<fx[j][i];
}}
};
void main()
{base k;
k.show();
}
char base::c=30;
|
|
|
|

|
im starting my work with c# and i have a problem with inheritance, i need one form to inherite after another one, it wouldnt be a problem but dialog class inherit after "Form", since in c# its only one inherit per class and dialog class cant run whitout "Form". how can i implement my own class into dialog class?
(sorry for my bad english)
|
|
|
|

|
Hi Guys ,
Could you please let me know how to consume the following REST service from C# code. Your answers will be very helpful. Thanks in advance.
Authenticate(POST)
http://localhost:50448/UserRest/GetSampleMethod_With_OAuth
json script -Request Body
{
"Password":"subin",
"UserName":"Subin"
}
Get All(GET)
http://localhost:50448/UserRest/getall?token={token}
Update(PUT)
http://localhost:50448/UserRest/update?token={token}
json script -Request Body
{
"Bank":"String content",
"DOB":"String content",
"ID":"1",
"Name":"String content"
}
Delete(DELETE)
http://localhost:50448/UserRest/delete/1?token={token}
Logout(POST)
http://localhost:50448/UserRest/LogoutSession?token={token}
With Regards
|
|
|
|

|
Hey guys,
I have this weird problem, when I want to open the FolderBrowserDialog, I can't select any folder on my phone! When I want to select a folder on my local HDD, there's no problem, but when it comes to the phone the select button get's deactivated and I can't select a folder. (see attached picture)
Here's the code I'm using:
private void button3_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
dialog.Description = "Open Folder";
dialog.ShowNewFolderButton = true;
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
if (dialog.ShowDialog() == DialogResult.OK)
{
textBox2.Text = dialog.SelectedPath;
}
}
}
What I want to do is copying my music to the phone, but therefore I need a path.
When I open the phone with Microsoft Explorer, the path is shown such as "Computer\GT-I9300\Card\Bluetooth" (that's the folder "Bluetooth" on the root of the external card of the phone). So there's no explicit path either! Is there any other way to get the path? Programs such as WinAmp or WMP can connect to the phone to copy files without any problems, so it must be possible somehow.
|
|
|
|

|
Instead of trying to type this up, which would take forever… I recorded my screen and uploaded it to YouTube.
Here is the link to the video:
[^]
using System;
namespace CalculatetothePowerof
{
class Program
{
static void Main()
{
AcceptValueOne();
}
static int AcceptValueOne()
{
Console.WriteLine("Enter your first number:");
string valueOne = Console.ReadLine();
int IntOne = 0;
bool result = Int32.TryParse(valueOne, out IntOne);
if (!result)
{
Console.WriteLine("Attempted conversion of '{0}' failed.", IntOne);
AcceptValueOne();
}
Console.WriteLine("\n{0}", IntOne + ", is what you entered?\n\nPress lowercase y for yes\nPress lowercase n for no.");
string yesNo = Console.ReadLine();
if (yesNo == "y")
{
AcceptValueTwo();
}
if (yesNo == "n")
{
Console.Clear();
AcceptValueOne();
}
else if (yesNo != null)
{
Console.Clear();
AcceptValueOne();
}
return IntOne;
}
static int AcceptValueTwo()
{
Console.WriteLine("\nEnter your second number:");
string valueTwo = Console.ReadLine();
int IntTwo = 0;
bool result = Int32.TryParse(valueTwo, out IntTwo);
if (!result)
{
Console.WriteLine("Attempted conversion of '{0}' failed.", IntTwo);
AcceptValueTwo();
}
Console.WriteLine("\n{0}", IntTwo + ", is what you entered?\n\nPress lowercase y for yes\nPress lowercase n for no.");
string yesNo = Console.ReadLine();
if (yesNo == "y")
{
CalcPowerOf();
}
if (yesNo == "n")
{
Console.Clear();
AcceptValueTwo();
}
if (yesNo != null)
{
Console.Clear();
AcceptValueTwo();
}
return IntTwo;
}
int valOne = AcceptValueOne();
int valTwo = AcceptValueTwo();
static void CalcPowerOf()
{
Program MyObj = new Program();
Console.WriteLine(Math.Pow(MyObj.valOne, MyObj.valTwo));
Console.Read();
}
}
}
When I changed this:
int valOne = AcceptValueOne();
int valTwo = AcceptValueTwo();
Into this:
int valOne = IntOne;
int valTwo = IntTwo;
Blue squiggly lines appear underneath both:
IntOne;
IntTwo;
Does not exist in the current context.
If you make any changes to my code, please explain what you're doing and why.
Thank you to all who took the time.
Rob
|
|
|
|

|
Hello All,
My windows form application which allows users to import, edit, and save images works for the most part. However, it lacks many features that I would like to have but I have no idea on how to go about creating them. On top of the list of features I'd like to have is the ability to create images on separate layers. Right now I can put paint on top of an image or lay one image on top of another image but once I do that I can not separate them since they are on the same layer. Any suggestion will be greatly appreciated thanks in advance.
|
|
|
|

|
How can C # Assistance WindowsFormsApplication1 save a text document in pdf-for example, in
The second question
Notify me when someone who has a calendar to "pay something" for example ...
I can not understand how the code should be written
|
|
|
|

|
Dear
am using gmail smtp means mail send ..working good but i have change smtp name username password nic.in means did not send mail
|
|
|
|
 |
Message Automatically Removed
|
|
|
|

|
Ok, here is my problem:- I have a tcp connection to an instrument; it is the slave and I am it's master (it speaks only when spoken to). Below is an example of how this conversation might look:-
Array.Clear(this.RXstring, 0, this.RXstring.Length);
sendMessage(buildMessage(Operation.Query));
System.Threading.Thread.Sleep(2000);
try
{
int len = this.tcp_com.Receive(this.RXstring);
string temp = ASCIIEncoding.ASCII.GetString(this.RXstring, 0, len);
if(temp.Contains("DYNAMIC")
{
this.dynamic = true;
}
else
{
this.dynamic = false;
}
}
Problem is this:- Sometimes, the data can be truncated or for some reason, maybe too big for the buffer and so a bit gets left behind. If I try and read without there being any data, it becomes stuck so I have made my buffer 1024 bytes long and added some time to try and make sure it's all arrived.
I would like to be able to clear the port somehow so that I know that there is only valid data when I get a responce and not something left over from last rx. Alternativey, I would like to be able to ask if there is data there without it crashing; I could then retrieve and discard myself.
I know that there are other ways I could have implemented the tcp bit but this seemed the simplest at the time.
As usual, all thoughts and advise gratefully received...
|
|
|
|

|
after I run my windows application(c#) program and entering some digits and add to one list(showing one gif image to load) suddenly,after 5 or 6 times the shape of all buttons and labels Gradually change into cross shape.but also this happens in just some computers.thanks very much if you can help me.
|
|
|
|
 |
Message Automatically Removed
|
|
|
|

|
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram
|
|
|
|

|
I am getting error Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) on the subject while trying to build this with Visual C#:
using System;
using System.Windows.Forms;
using SKYPE4COMLib;
namespace SkypeBing
{
public partial class Form1 : Form
{
private Skype skype;
private const string trigger = "!"; private const string nick = "BOT";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
skype = new Skype();
skype.Attach(7, false);
skype.MessageStatus +=
new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
}
private void skype_MessageStatus(ChatMessage msg,
TChatMessageStatus status)
{
string command = msg.Body.Remove(0, trigger.Length).ToLower();
skype.SendMessage(msg.Sender.Handle, nick +
" Says: " + ProcessCommand(command));
}
private string ProcessCommand(string str)
{
string result;
switch (str)
{
case "uli":
result = "http://www.youtube.com/watch?v=VfvBQMqCZw8";
break;
default:
result = "Uliuli";
break;
}
return result;
}
}
}
Whole error:
Error 1 The type or namespace name
That is the whole error.
Line 99 Column 33
modified 13 May '13 - 10:45.
|
|
|
|

|
Please help me to do this operations by using Asp.Net
1.Several screens (or one very functional one) to view the data in a variety of ways like by Phase, by ESXHost, by Application.
I think if we have several drop downs for filtering then that would work; so I can choose Phase 1, to show only the databases that will be migrated in Phase 1, then I can choose some other criteria and the screen shows a subset of data etc.
2. The Pre-requisites and Post-Migration checks should show whether the Phase or database migration is ready to start or is ok to complete.
|
|
|
|

|
I would suggest reading an excellent book called CLR Via C# by Jeffrey Ritcher.
You'll get good understanding about C# features, its compiler, some IL code examples, CLR (JIT) mechanisms.
Its easy to read and understand.
It is must have for a C# developer.
Be a good professional who shares programming secrets with others.
|
|
|
|

|
Its probably something to do with my RegEx but I can't get it to be case insensitive.
My regex is (\xAB" + col.ColumnName + "\xBB) (The \xAB and \xBB are the double chevron quote chars)
So my code block is:
Regex regex = new Regex("(\xAB" + col.ColumnName + "\xBB)", RegexOptions.IgnoreCase);
docText = regex.Replace(docText, ds.Tables[0].Rows[0][col].ToString());
I've also tried:
docText = Regex.Replace(docText, "(\xAB" + col.ColumnName + "\xBB)", ds.Tables[0].Rows[0][col].ToString(), RegexOptions.IgnoreCase);
What have I ballsed up? Something with the literal I imagine.
|
|
|
|

|
I've been at this for two days now. My code compiles just fine, the compiler sort of kind of understood what I was trying to do. Because I didn't comment on any of my code, I'll do my best to do it right here. Ask the user for a number. Preset number back to the screen and ask if it is correct. If it is correct, move on to next block of code. If that is not correct, clear the screen and start over. If the first number was correct, ask for the second number. Present second number back to the screen and ask if it is correct. If it is correct, move on to the next block of code. If it is not correct, clear the screen and start over by asking for the second number again. Apparently, I can't use the integer value returned by the method number one or the integer value returned by the method number two. Console.WriteLine(Math.Pow(firstUserNum, secondUserNum)); I renamed the variables and attempted to use those instead, that didn't work either. Then I tried to explicitly invoke by using: Console.WriteLine(Math.Pow(Program.CalculatetothePowerof.firstUserNum.firstUserIntValue, then same thing here)); I know I'm so close, yet so far away… Here is my code: (you old pros, don't laugh when you compile this and run it… I said don't laugh!) <pre lang="c#"> using System; namespace CalculatetothePowerof { class Program { static void Main() { tellUserFirstTime(); firstUserNum(); YesOrNo(); tellUserSecondTime(); secondUserNum(); secondYesOrNo(); Console.ReadKey(); } private static void tellUserFirstTime() { Console.Write("Enter your first number:\n"); } private static int firstUserNum() { int firstUserIntValue; string userValue; userValue = Console.ReadLine(); Console.WriteLine("You entered {0}?\n", userValue); firstUserIntValue = Convert.ToInt32(userValue); return firstUserIntValue; } private static void YesOrNo() { string userAns; Console.WriteLine("If that is correct, press the letter y.\nIf it's not correct, press the letter n."); userAns = Console.ReadLine(); if (userAns == "y") tellUserSecondTime(); if (userAns == "n") { Console.WriteLine("We'll start over.\nPress any key to start over."); Console.ReadKey(); Console.Clear(); tellUserFirstTime(); } else if (userAns != "y" || userAns != "n") { Console.WriteLine("You must press lowercase y\nOr\nLowercase n\nWe'll start over again\nPress any key to start over"); Console.ReadKey(); Console.Clear(); tellUserFirstTime(); } } private static void tellUserSecondTime() { Console.Write("Enter your second number:\n"); } private static int secondUserNum() { int secondUserIntValue; string secondUserValue; secondUserValue = Console.ReadLine(); Console.WriteLine("You entered {0}?\n", secondUserValue); secondUserIntValue = Convert.ToInt32(secondUserValue); return secondUserIntValue; } private static void secondYesOrNo() { string userAns; Console.WriteLine("If that is correct, press the letter y.\nIf it's not correct, press the letter n."); userAns = Console.ReadLine(); if (userAns == "y") Console.WriteLine("Widmark, you're a genius!"); //calcFirstAndSecondNum(); if (userAns == "n") { Console.WriteLine("We'll start over.\nPress any key to start over."); Console.ReadKey(); Console.Clear(); tellUserSecondTime(); } else if (userAns != "y" || userAns != "n") { Console.WriteLine("You must press lowercase y\nOr\nLowercase n\nWe'll start over again\nPress any key to start over"); Console.ReadKey(); Console.Clear(); tellUserSecondTime(); } } /*private static void calcFirstAndSecondNum() { Console.WriteLine(Math.Pow(firstUserNum, secondUserNum)); }*/ } } </pre> <a href="http://www.widmarkrob.com">My Coding Journey</a>
|
|
|
|
|

|
Hi. In theory I think is about right but for some reason it doesn't work. Any ideas? Thank you very much for your help!
public delegate void PullFunction(GameObject o);
if (Object.S1NPCDataController.Name == "name1") return false;
if (Object.S1NPCDataController.Name == "name2") return false;
if (Object.S1NPCDataController.Name == "name3") return false;
[18-1-19] Compile file : 1212.cs
[18-1-19] [COMPILER] Compilation error !
[18-1-19] Line number : 310, Error Number : CS1519, 'Symbol 'if' not valid
[18-1-19] Line number : 310, Error Number : CS1519, 'Symbol '==' not valid
[18-1-19] Line number : 311, Error Number : CS1519,'Symbol '==' not valid
[18-1-19] Line number : 312, Error Number : CS1519, 'Symbol '==' not valid
|
|
|
|
 |
|